[Issue 21745] Closure created in struct constructor passed to class constructor refers to expired stack frame

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 25 14:16:20 UTC 2021


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

--- Comment #11 from anonymous4 <dfj1esp02 at sneakemail.com> ---
(In reply to FeepingCreature from comment #7)
> This is indeed a problematic case. We want "this" to reference the variable
> on which the struct method was called. But we also want the stackframe to be
> heap allocated, so we can return a closure. It seems those two requirements
> may simply not be simultaneously satisfiable? I'm not sure which one should
> take precedence.

They are separated in time. First the struct is allocated, then the constructor
is called on it, it's too late for the constructor to change the allocation
strategy, because the allocation already happened.

--


More information about the Digitalmars-d-bugs mailing list