[Bug other/16051] New: Static libraries with global static initializer that have side-effect to main are removed at link

nct at ysagoon dot com gcc-bugzilla@gcc.gnu.org
Fri Jun 18 09:22:00 GMT 2004


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



More information about the Gcc-bugs mailing list