Delegate is left with a destroyed stack object
Ali Çehreli
acehreli at yahoo.com
Tue Oct 29 14:37:43 PDT 2013
On 10/29/2013 02:32 PM, David Nadlinger wrote:
> The problem with the compiler behavior for the code in question is that
> it destructs a live object, and thus clearly breaks the type system.
>
> I think the only correct resolution is to not destruct the object at the
> end of foo() – which incidentally also means that the destructor will
> never be invoked, just as for any other GC-finalized memory.
To add to that, Maxim Fomin notes in the D.learn forum that there are
the following conflicting requirements:
1) need to allocate struct into heap due to lambda
2) need to put dtor invocation in the end as usual.
The first one is supported by the closure spec. The second one is the
well-know struct destruction upon leaving a scope.
Ali
More information about the Digitalmars-d
mailing list