[Issue 2043] Closure outer variables in nested blocks are not allocated/instantiated correctly: should have multiple instances but only have one.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 5 20:36:29 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=2043

--- Comment #33 from timon.gehr at gmx.ch ---
(In reply to Walter Bright from comment #32)
> > Other programming languages, even those that always capture by reference, do not have this problem.
> 
> So, for a variable declared in a loop, where do they allocate storage for it?

For some, this is an implementation detail, others explicitly specify heap
allocation.

In D, if the compiler can prove that closures don't escape, alloca might be an
option.

--


More information about the Digitalmars-d-bugs mailing list