More range woes: composed ranges are unsafe to return from functions

Timon Gehr timon.gehr at
Tue Oct 16 15:04:49 PDT 2012

On 10/16/2012 09:47 PM, jerro wrote:
>> Hmm. There *is* a delegate being passed to map(). Would that cause
>> problems? Theoretically it shouldn't, but as you said, if dmd isn't
>> handling it correctly that could cause problems.
> I'm looking at the disassembly of cprod (
> and there doesn't seem to be a call to _d_allocmemory in it. AFAIK it
> should be if the memory for the variables that the delegate uses was
> allocated on the heap?

It should certainly allocate a closure. However, we don't want hidden
allocations in Phobos, so an alternate implementation strategy that
captures the input by value would be preferable anyway.
The bug should be reported in each case.

More information about the Digitalmars-d mailing list