Destructor called while object is still alive

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Oct 23 13:11:49 UTC 2020


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().





More information about the Digitalmars-d mailing list