This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: failure to construct global object
- To: gisli at adams dot com
- Subject: Re: failure to construct global object
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Mon, 6 Mar 2000 09:39:52 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <200003060422.XAA14994@euler.adams.com>
> 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