Destructor called while object is still alive

Boris Carvajal boris2.9 at gmail.com
Fri Oct 23 13:23:18 UTC 2020


On Friday, 23 October 2020 at 13:11:49 UTC, Ola Fosheim Grøstad 
wrote:
> On Friday, 23 October 2020 at 12:53:52 UTC, Boris Carvajal 
> wrote:
>> That means in OP example 'scope' does nothing, it's just like 
>> 'auto' and the class is heap allocated.
>
> Hm. I think what happens is that exit() makes the destructor 
> call unreachable therefore the pointer to the object is not 
> saved on the stack and not retained in any registers. Thus 
> GC.collect finds no references to it.
>
> It works if you remove exit().

exit() is irrelevant, I checked the asm output.


More information about the Digitalmars-d mailing list