------- Comment #2 from ajd at gentrack dot com 2007-10-09 01:48 ------- Created an attachment (id=14325) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14325&action=view) testcase shows constructors running in incorrect order
Compile like: g++ -shared -o liba1.a -D LIBNAME=LIB1 test_init_order.cpp g++ -shared -L. -la1 -o liba2.a -D LIBNAME=LIB2 -DCALLEE=LIB1 test_init_order.cpp g++ -shared -L. -la2 -o liba3.a -D LIBNAME=LIB3 -DCALLEE=LIB2 test_init_order.cpp g++ -L. -la3 -o m -D LIBNAME=main -DCALLEE=LIB3 test_init_order.cpp Creates libraries dependencies like: m -> LIB3 -> LIB2 -> LIB1 Expected output is: LIB1_init LIB2_init LIB3_init main_init main() LIB3() LIB2() LIB1() main_fini LIB3_fini LIB2_fini LIB1_fini Actual output is: main_init LIB3_init LIB2_init LIB1_init main() LIB3() LIB2() LIB1() LIB1_fini LIB2_fini LIB3_fini main_fini -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33704