rvyas <rishabh.a.vyas@xxxxxxxxx> writes: > We recently had a weird memory corruption issue in our project during > destruction. The problem boiled down to order of destruction of > statics. They should have been destroyed in the exact reverse order of > the completion of their respective constructors. However gcc did not > preserve the order of destruction across block scope statics and > namespace scope statics. As far as I know, that should work. However, if your program uses dlopen, then gcc needs the __cxa_atexit function to destroy globals in the right order. And with regard to __cxa_atexit: > /var/tmp//cc3nl8Dr.o: In function > `__static_initialization_and_destruction_0(int, int)': > temp.cpp:(.text+0x6a): undefined reference to `__cxa_atexit' there's the problem. The __cxa_atexit function is available in glibc on GNU/Linux systems but is not in the Solaris library. I don't know of a way to run destructors in the right order in the presence of dlopen without __cxa_atexit. Ian