UnitTest destruction order?


#1


Hi, 


A non-local static UnitTest class registers itself in a static local Array (by calling getAllTests( )) in its constructor. While in its destructor this class unregisters from that Array. Is there any C++ rule in the standard that manages the order of those destructions (to guarantee that the non-local static class is destroyed before the local static class) or is it undefined?  


NB: I can not find a definitive response (browsing with google). Help is welcomed.
 


#2

Oops, i should have searched a bit more.

So according to:

3.6.3/1 

"If the completion of the constructor or dynamic initialization of an object with static storage duration is sequenced before that of another, the completion of the destructor of the second is sequenced before the initiation of the destructor of the first."

And:

http://stackoverflow.com/questions/3736212/destruction-of-objects-with-static-storage-duration

That is not undefined. That is safe.