www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Destructors

reply pragma <pragma_member pathlink.com> writes:
I know it was brought up a while back, but I wanted to check with the group and
make sure that it's still the case.

D's destructors are not to be called from within other destructors, correct? (or
more succinctly: do not use 'delete' in a dtor)

I just ran into an issue where I was using 'delete' down the call chain from a
module dtor.  It routinely causes a fault in "__d_delclass", according to MSVC's
debugger. 

- EricAnderton at yahoo
Feb 04 2005
parent "Ben Hinkle" <ben.hinkle gmail.com> writes:
"pragma" <pragma_member pathlink.com> wrote in message 
news:cu1d76$rmi$1 digitaldaemon.com...
I know it was brought up a while back, but I wanted to check with the group 
and
 make sure that it's still the case.

 D's destructors are not to be called from within other destructors, 
 correct? (or
 more succinctly: do not use 'delete' in a dtor)

 I just ran into an issue where I was using 'delete' down the call chain 
 from a
 module dtor.  It routinely causes a fault in "__d_delclass", according to 
 MSVC's
 debugger.

 - EricAnderton at yahoo
correct. A destructor cannot assume any other GC-managed resource is alive. The order in which the memory is reclaimed in a given GC pass is undefined.
Feb 05 2005