Destructor of a static object constructed within the destructor of another static object
I have some problems with destructor, in next code: #include <stdlib.h> #include <cstdio> class Foo2 { public: Foo2() { printf("foo2 const\n"); } ~Foo2() { printf("foo2 dest\n"); // <--- wasn't called for bionic libc } }; static Foo2& GetFoo2() { static Foo2 foo2; printf ("return foo2\n"); return foo2; } class Foo1 { public: Foo1() { printf("foo1 const\n"); } ~Foo1() { printf("foo1 dest\n"); GetFoo2(); } }; int main( int argc, const char* argv[] ) { printf("main 1 \n"); static Foo1 anotherFoo; printf("main 2 \n"); } Why destructor for foo2 wasn't called for bionic and was for glibc ? EDIT