Heisenbug involving Destructors & GC - Help Needed

Etienne Cimon via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 26 20:51:21 PDT 2015


On 2015-06-26 23:44, Temtaime wrote:
> Disagree. Destroy on a pointer calls dtor of a struct.
> Why it should be an error ?

Exactly what I assumed too. Can you imagine all of the random errors 
that stem from such a basic, low-level assumption? I carry a scar for 
every day I've spent in the debugger, and this bug has given me its load 
of torments. Of course, I'm the only one to blame, I didn't know:

import std.stdio;

void main() {
         struct A { ~this() { writeln("Dtor"); } }
         A* a = new A;
         destroy(a);
         writeln("Done");
}

output: Done


More information about the Digitalmars-d mailing list