From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25020 invoked by alias); 6 Nov 2012 14:46:53 -0000 Received: (qmail 24989 invoked by uid 48); 6 Nov 2012 14:46:35 -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: Tue, 06 Nov 2012 14:46: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: 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/msg00482.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791 --- Comment #13 from David Edelsohn 2012-11-06 14:46:34 UTC --- > Because if you have a function declared as inline in a header file that gets propagated to multiple source files is ok, but in my case that inline keyword was removed by some $ifdef LINUX and so I end up with having the constructor body defined in the header like this: ClassA::ClassA(){//body}. Now because this is in the header it will propagate to all sources that includes it. So finally I end up with that constructor in multiple constructors sources. This would not happen if the inline keyword have not been removed from it. This was a bug in our code and I removed it. Okay, so the problem was *lack* of inlined constructors. Now that makes more sense. > Our project has one exe and several shared and static libs. To make the things easier I moved every source file in the exe. Now the problem I have is with the order of the initialization of global objects that reside in multiple object files. I need objects in a source file by constructed first before any other objects in the rest of the files are constructed. If you actually create shared libraries, you should add -fPIC to the compilation command. This also adds some additional uniqueness to symbols. > You said that I can decorate the constructors with a priority. How to do that ? Before migrating from xlC we used #pragma priority. This is ignored by gcc. We also used -qpriority flag of xlC. Also gcc does not have something like this. Or? Use __attribute__ ((init_priority (NNNN))) http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html