From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8402 invoked by alias); 5 Nov 2012 14:34:55 -0000 Received: (qmail 4850 invoked by uid 48); 5 Nov 2012 14:34:28 -0000 From: "adivilceanu at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54791] AIX-only: Constructors are not called in main program. Date: Mon, 05 Nov 2012 14:34: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: adivilceanu at yahoo dot com 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/msg00370.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791 --- Comment #10 from Adi 2012-11-05 14:34:25 UTC --- I found the real problem ! Now it can be reproducible even with a small test case. I can summarize it like this: If you have a global object/function defined in "n" different object files, then the constructors in the "n-1" object files might not be invoked at all. This will happen always for sure if the object/function is the first thing defined in those object files. Explination: Each object file when complied with g++ for AIX, will get a _GLOBAL__I_65535_0__***name_of_first_object_defined_in_this_compilation unit***. Now if there are 2 object file that have defined in them an object/function with the same name/signature then these 2 object files will get the same _GLOBAL__* symbol. Now later when the collect2 is involved it will take just one _GLOBAL__* into account. It will ignore the other n-1 symbols and so n-1 object remain with all their object's constructors not called. Given the above I have fixed my project not to have this situation(object with same name in multiple compilation units) and every constructor in my project is called now ! So it has nothing to do with inline as I first suspected. My inline sub-problem just was a side-effect of the real problem. Do you consider this being a bug? I think it is. Even if no fix is provided at least for me now something that would have been very usefull is if collect2 would have issued a more explicit message like "Multiple definitions of global objects with the same name; Some global objects will not be initialied !". I mean in the collect2 it is known that if it encounters this situation that there will be objects that will remain not-initialized. Right? Now that I solve this problem I have one new problem: It is related to the order of initialization of global objects across multiple compilation units. Shout I continue on this thread or open a new one? I am not sure its a bug.. I first have some questions on it.