This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: failure to construct global object


> The problem seems to be that the constructor for this object is never
> called.  

Thanks for your bug report. Without seeing any details, I'd claim that
the compiler is working properly, and that you made some
mistake. Again, it is then hard to guess what the mistake could have
been, but here are some options:

a) the object file containing the global object is not linked into the
   executable. That could happen if it is in a library, and none of the
   symbols in that object file are referenced.

b) The object will be created, but not at the time you are expecting
   it to be created. In C++, order of creation of global objects is
   unspecified - except that they must be initialized some time before
   they are first referenced from inside main (or functions called by
   main). In g++, construction order depends on the order in which
   object files are provided to the linker.

c) something else :-)

>  1) How do I gather useful information about this problem so that
>     I may write a proper bug report.

The object should be constructed in the object file containing its
definition. So please send preprocessor output and assembler code for
that file; you'll probably need to bzip2 them because of the mailing
list limit.

>  2) Are there any ways to coerce the construction.

As I said: If you have a well-formed C++ program, the compiler *will*
make sure that the object is constructed, so there is no mechanism to
coerce construction beyond that guarantee.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]