http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60731
Bug ID: 60731 Summary: dynamic library not getting reinitialized on multiple calls to dlopen() Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tim.moloney at mrsl dot com Created attachment 32518 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32518&action=edit Example showing failure to initialize a dynamic library after multiple calls to dlopen(). If a dynamic library is loaded multiple times via dlopen(), subsequent loads do not correctly initialize static variables under the following conditions: 1) A class/struct with a constructor 2) with an inlined function 3) containing a static variable. Please run the attached example. # tar xf gcc_static_issue.tgz # cd gcc_static_issue # make # ./test_static Expected behavior (as on RHEL5, g++ 4.1.2): Type 'q' to exit or enter to reload/run the DLL count:1 count:1 count:1 count:1 count:1 q # Actual behavior (as on RHEL6 and RHEL7beta, g++ 4.4.7 and 4.8.2, respectively): Type 'q' to exit or enter to reload/run the DLL count:1 count:2 count:3 count:4 count:5 q #