When two separate Dynamic Shared Objects (DSO's) are using the same static object with the same name and each of them keeps a local copy of that object. When the application gets loaded that objects constructor is called twice for the same instance and the destructor is also called twice when the main application exits. The Ctor is called for each load of the shared object and the Dtor for each close of the library. Regardless that the linker has optimized the instance so there would be one instance and not two.
When applying the static prefix the problem is solved but the code is merged and the second linked shared object gets to execute the code of the first one! -- Summary: Dynamic linking cause static Dtor and Ctor to ran twice on same instance Product: gcc Version: 3.4.5 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ranc at mobixell dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32688