I have a variable of a class type. The side-effect of the constructor is registering and ordering some stuff in a table. The variable is declared in main. It is not used otherwise in main. Thus I want to achieve that the table's contents is set up properly while main is running, i.e. after global constructor runtime but before anything else interesting happens. I tried to find a trivial test case, but trivial cases work fine. So here comes the big one. Attached is preprocessed C++-file trader-main.ii I compiled with the command g++-3.4 -v -S -O -fno-exceptions trader-main.ii (The bug also happens when I replace -O by -g. Then I see when stepping through the program, how the debugger omits the lines instantiating the variables in question.) The variables are of class "Lingo", constructor declared in line trader-main.ii:13863 The variable instantiations inside main is in lines trader-main.ii:46019 through 46021 You see clearly in the resulting assembly code, that these constructor calls are missing at the beginning of main. There should be three calls to "Lingo::Lingo" around line trader-main.s:310 The corresponding destructor calls are generated in lines trader-main.s:396 ff. Thank you for your time. Ups, where do I attach the files to this form? I'll submit it now and try to add them later.
Created attachment 6198 [details] The specs file from the compiler I've built here on Linux.
Created attachment 6199 [details] How I compiled the preprocessed source file plus compiler messages.
Created attachment 6200 [details] The preprocessed source file.
Created attachment 6201 [details] The resulting assembler source, which hopefully shows the problem.
I just tried it on solaris-8 for sparc, with the compiler prebuilt from sunfreeware.com: $ /usr/local/bin/g++ -v -help Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.8/3.4.0/specs Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls Thread model: posix gcc version 3.4.0 $ Same problem.
Invalid, this code is equivent to this simplifed case: struct Lingo { Lingo (); }; struct ALingo : Lingo { ALingo(); }; int main() { ALingo a; Lingo b(a); // <-- calls the copy constrctor } Since there is no user defined copy constructor, the compiler creates one for you (by the rules of C++). So this is invalid, to solve this you need to define a copy constructor.