This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7769: using static libraries sometimes loses static initialization
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, hablack at vt dot edu, nobody at gcc dot gnu dot org
- Date: 20 Dec 2002 01:40:05 -0000
- Subject: Re: c++/7769: using static libraries sometimes loses static initialization
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, hablack at vt dot edu, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: using static libraries sometimes loses static initialization
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Thu Dec 19 17:40:05 2002
State-Changed-Why:
This is not a bug. When you want that a particular
object file (possibly within an archive) is pulled into you
executable for sure, then you have to reference an object
inside it.
If you rename your class "A" to "ComplexClass", to make
its symbols better visible in the executable, you
see that the object file with the static constructor
is not even pulled into the executable:
g/static_init> nm main1 | grep ComplexClass
080485f0 W __12ComplexClass
g/static_init> nm main2 | grep ComplexClass
g/static_init> nm main3 | grep ComplexClass
g/static_init> nm main4 | grep ComplexClass
080485f0 W __12ComplexClass
I guess this is just how the linker works.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7769