www.digitalmars.com         C & C++   DMDScript  

D - Re: [BUG] gc & static & templates

reply Sark7 <sark7 mail333.com> writes:
Also, in the following program dtor is not called.

[code]
template TFoo(T) {
   T t;
}

class C {
   this() {
     printf("ctor"\n);
   }
   ~this() {
     printf("dtor"\n);
   }
}

void main() {
   TFoo!(C).t = new C();	
}
[/code]
Apr 24 2004
parent Craig Pennington <cpenning milo.org> writes:
Sark7 wrote:
 Also, in the following program dtor is not called.
[snip] The template stuff is unneccesary, this is all part of the same behavior -- globally alloacted class cleanup is not happening; it's being passed off to the OS. This is a problem for globally allocated classes that somehow indicate closing state in their dtors rather than just releasing memory. Walter, is it the case that global class instances should have their dtors called at program termination? Cheers, Craig
Apr 25 2004