http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791



David Edelsohn <dje at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

             Status|UNCONFIRMED                 |NEW

   Last reconfirmed|                            |2012-11-03

     Ever Confirmed|0                           |1



--- Comment #9 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-03 22:48:06 
UTC ---

> So just to be 100% sure on this: If I want to be sure all my constructors are

> called I should not have any of them inlined. Correct ?

> What about if I have a constructor body/implementation inside a class

> declaration ? Does the compiler inline that as well? I guess it might.



I am not positive that inlining is the problem, but that seems like a good

hypothesis.  collect2 scans object files looking for constructors by name,

e.g.,



GLOBAL__I_<xxxx>



You can look at the global symbols using



$ nm -BCpg xxxx.o



If the constructors are visible when NOT inlined and disappear when they are

inlined, that is the problem.  If "nm" cannot see them, the mechanism for

creating the list of constructors (and destructors) cannot see them either.



> So how do you see this case. Is it not a bug? I mean I am expecting my

> constructors to be called and they are not.

> Do you know a easy way to solve this without modifying all my constructors ?

> (any compiler options perhaps, ..using __attribute__((constructor)) ) ?



The methods already are constructors.  Additional attributes will not make a

difference.



If you can create a small, self-contained testcase with a constructor that

works or does not work depending on inlined, I can look. I am not sure how

inlined constructors are recorded in ELF files.  This sounds like a bug, but it

will take some investigation to figure out how difficult it is to fix given the

behavior of AIX and GCC.  Inlined constructors may not be a practical option on

AIX.



Also, please use the GCC Bugzilla interface for comments and attaching

testcases, not email replies. There probably is a way to add attachments using

email, but I do not know how and Bugzilla is much more useful without all of

the email history already present in the comment history.

Reply via email to