public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "adivilceanu at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/54791] New: AIX-only: Constructors are not called in main program.
Date: Wed, 03 Oct 2012 09:20:00 -0000	[thread overview]
Message-ID: <bug-54791-4@http.gcc.gnu.org/bugzilla/> (raw)


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

             Bug #: 54791
           Summary: AIX-only: Constructors are not called in main program.
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: adivilceanu@yahoo.com


I work on a very big project on AIX 6.1(TL5 SP7). I migrated from xlC to
gcc(v4.7.2). I have the problem that constructors of a global objects defined
almost anywhere are not called. After searching a lot on this I saw this could
be if the objects are in libs(static or shared) and not referenced. This is not
my case because my global object is defined in the main source file(where main
is defined) and they are referenced.
I try to isolate the problem so I removed all the code from my main source file
and just let the following code:

#include <mybigtreeofconfidentialheaders.h>

class Adiv{
public:
    Adiv(char in_name[])
    {
        printf("Adiv()=%s\n",in_name);
        strcpy(name,in_name);
    }
    ~Adiv()
    {
        printf("~Adiv()=%s\n",name);
    }
    void f()
    {
        printf("f()name=%s\n",name);
    }
    char name[32];
    int x;
};

Adiv a("a");
static Adiv b("b");

int main()
{
    static Adiv c("c");
    a.f();
    b.f();
    c.f();
    return 0;
}


After building and executing I get the following output:
Adiv()=c
f()name=
f()name=
f()name=c
~Adiv()=c

Now, if I remove the #include <mybigtreeofconfidentialheaders.h> then I get the
correct output:
Adiv()=a
Adiv()=b
Adiv()=c
f()name=a
f()name=b
f()name=c
~Adiv()=c
~Adiv()=b
~Adiv()=a

The line I use to compile is:
g++ -c   -w -fno-strict-aliasing -fpermissive -save-temps -DMYCUSTOM_DEFINES
-DIALL_CHECKS -D_AIX_PTHREADS_D7   -Imy_custom_includes main.cpp
The line I use to link is:
g++ -Wl,-bmaxdata:0x40000000
-Wl,-blibpath:/usr/lib/threads:/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.7.2:/usr/lib:/lib
 -Wl,-bloadmap:/map.txt -omyexe main.o myobj_1.o myobj_2.o ...myobj_n.o

I want to mention that beside the pdsmain.cpp I have a lot of other
confidential cpp that I compile and link with pdsmain.cpp, but that should not
affect the constructors calling in the main object file, correct ?

So my basic question is: What could cause the constructors not to be called ?
Its definitely has to do with the big tree of headers. I can not provide them
as they are confidential.
I tried the same build (with the big tree of headers) on Linux and there it
works ! 

If needed I think I can provide the assembly file of the main.cpp with and
without the big tree of headers for you to see the differences.

One more thing:
This thread seems to have the same problem as me but it was never solved:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=2413#c3.
See the comment from " David Obermann 2006-09-20 06:38:07 UTC ".

It seems in both cases the problem is reproducible with big applications on
AIX.
Could be the very number of global objects? Big TOC ?


             reply	other threads:[~2012-10-03  9:20 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-03  9:20 adivilceanu at yahoo dot com [this message]
2012-10-03  9:40 ` [Bug target/54791] " paolo.carlini at oracle dot com
2012-10-03 13:47 ` dje at gcc dot gnu.org
2012-11-02 14:49 ` adivilceanu at yahoo dot com
2012-11-02 14:52 ` adivilceanu at yahoo dot com
2012-11-03  6:21 ` adivilceanu at yahoo dot com
2012-11-03  6:24 ` adivilceanu at yahoo dot com
2012-11-03 13:49 ` dje at gcc dot gnu.org
2012-11-03 19:15 ` adivilceanu at yahoo dot com
2012-11-03 22:48 ` dje at gcc dot gnu.org
2012-11-05 14:34 ` adivilceanu at yahoo dot com
2012-11-05 18:55 ` dje at gcc dot gnu.org
2012-11-05 21:14 ` adivilceanu at yahoo dot com
2012-11-06 14:46 ` dje at gcc dot gnu.org
2012-11-06 16:23 ` adivilceanu at yahoo dot com
2012-11-06 21:50 ` adivilceanu at yahoo dot com
2012-11-07  1:27 ` dje at gcc dot gnu.org
2012-11-07 14:46 ` adivilceanu at yahoo dot com
2012-11-07 15:25 ` adivilceanu at yahoo dot com
2012-11-07 22:15 ` dje at gcc dot gnu.org
2012-11-13  8:21 ` adivilceanu at yahoo dot com
2012-11-13  8:30 ` adivilceanu at yahoo dot com
2012-11-13 14:03 ` dje at gcc dot gnu.org
2012-11-13 14:09 ` adivilceanu at yahoo dot com
2012-11-14 14:20 ` dje at gcc dot gnu.org
2012-11-27 15:54 ` adivilceanu at yahoo dot com
2012-11-27 18:55 ` adivilceanu at yahoo dot com
2012-11-27 19:01 ` adivilceanu at yahoo dot com
2012-11-27 20:42 ` dje at gcc dot gnu.org
2012-11-28 14:01 ` adivilceanu at yahoo dot com
2012-11-28 19:35 ` dje at gcc dot gnu.org
2012-11-29  9:35 ` adivilceanu at yahoo dot com
2012-11-29  9:44 ` adivilceanu at yahoo dot com
2012-12-01 21:42 ` dje at gcc dot gnu.org
2015-03-18 12:42 ` dje at gcc dot gnu.org
2015-03-18 12:49 ` dje at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-54791-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).