From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2805 invoked by alias); 3 Nov 2012 22:48:34 -0000 Received: (qmail 2717 invoked by uid 48); 3 Nov 2012 22:48:09 -0000 From: "dje at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54791] AIX-only: Constructors are not called in main program. Date: Sat, 03 Nov 2012 22:48:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: dje at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Last reconfirmed Ever Confirmed Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg00233.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791 David Edelsohn changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-11-03 Ever Confirmed|0 |1 --- Comment #9 from David Edelsohn 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_ 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.