This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32688] New: Dynamic linking cause static Dtor and Ctor to ran twice on same instance
- From: "ranc at mobixell dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jul 2007 07:00:55 -0000
- Subject: [Bug c++/32688] New: Dynamic linking cause static Dtor and Ctor to ran twice on same instance
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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 object?s 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