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]
Other format: [Raw text]

[Bug c++/15229] New: Omits constructor calls for variables not used otherwise.


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.

-- 
           Summary: Omits constructor calls for variables not used
                    otherwise.
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: duz at sol-3 dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


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


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