destructor ~this() for static "members." doesn't seem to get called

sclytrack sclytrack at pi.be
Sun Feb 18 12:14:03 PST 2007


import std.stdio;

class Testb
{
	this()
	{
		writefln("testb constructor");
	}
	~this()
	{
		writefln("testb destructor");		//Doesn't output on screen.
	}
}

class Testy
{
	static Testb inner = null;	//Destructor of Testb doesn't appear to be called.

	this()
	{
		writefln("testy constructor");
		inner = new Testb();
	}
	~this()
	{
		writefln("testy destructor");
	}
}

int main()
{
	writefln("gdc version 0.22");
	Testy t = new Testy();
	return 0;
}


It outputs the following lines:
./a.out
gdc version 0.22
testy constructor
testb constructor
testy destructor


The destructor of testb doesn't get called,
before the termination of the application,
or that is at least my perception.

Go go D, go :-)


More information about the D.gnu mailing list