This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/16051] New: Static libraries with global static initializer that have side-effect to main are removed at link
- From: "nct at ysagoon dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jun 2004 09:22:50 -0000
- Subject: [Bug other/16051] New: Static libraries with global static initializer that have side-effect to main are removed at link
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Static libraries with global static initializer that have side-effect to main
are removed at link. Here is a simple example :
You want to have a registrar in your main program that register classes in
static libraries that are linked with it. In each static library, you have a
global static instance of a class that register a class creator in the global
registrar in its constructor. The linker completly removes the library code
even if there is statics objects that have side effect in their constructors.
I've created a very simple test case, it is available here :
http://lsapc89.epfl.ch/~nct/gcc-static-init-lib-bug.tar.gz
Thanks,
Stephane
--
Summary: Static libraries with global static initializer that
have side-effect to main are removed at link
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nct at ysagoon dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386
GCC host triplet: i386
GCC target triplet: i386
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16051