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

Jonathan M Davis jmdavisProg at gmx.com
Tue Oct 16 15:11:12 PDT 2012


On Wednesday, October 17, 2012 00:04:49 Timon Gehr wrote:
> 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 (http://pastebin.com/ngTax6B8)
> > 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.

The allocation of closures is pretty much inevitable when we have delegates 
and/or non-static Voldemort types.

- Jonathan M Davis


More information about the Digitalmars-d mailing list