www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Order of destruction - static vs dynamic destructors

reply "antiAlias" <fu bar.com> writes:
There are three individual 'types' of destructor:

a) class
b) class static
c) module static

In which order are these invoked during shutdown? If, for example, there is
a fixed order whereby all static destructors are invoked first, then some of
the issues regarding non-deterministic 'liveness' of object references can
be handled more effectively during shutdown.

So, what's the scoop?

Thanks.
Aug 30 2004
parent "Walter" <newshound digitalmars.com> writes:
"antiAlias" <fu bar.com> wrote in message
news:cgvrri$2pn0$1 digitaldaemon.com...
 There are three individual 'types' of destructor:

 a) class
 b) class static
 c) module static

 In which order are these invoked during shutdown? If, for example, there

 a fixed order whereby all static destructors are invoked first, then some

 the issues regarding non-deterministic 'liveness' of object references can
 be handled more effectively during shutdown.

 So, what's the scoop?

class destructors may never be run unless they are 'auto'. If they are run, they are run before the static destructrors. Static class destructors and static module destructors are run in the lexical order in which they appear, in the reverse order that the static initializers were done.
Sep 09 2004