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



             Bug #: 55922

           Summary: brace initializing parent cause bogus virtual base

                    constructor calls

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: nicolas.cavall...@lri.fr

              Host: x86_64-unknown-linux-gnu

            Target: x86_64-unknown-linux-gnu





Created attachment 29128

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29128

minimal program which does not work.



The attached minimal c++11 source compiles with g++ -std=c++11 minimal.c++, but

the program does not run as expected (indicated by a non-zero exit value).

Using clang works.



The same source with debug outputs shows that the virtual base constructor is

called more than once upon initialization with bogus 'this' pointers. Not all

classes agree on the offset to the virtual base. This causes silent member

corruption (and ultimately crashes if some of the members are pointers).



Replacing brace initializers for B1 and A2 with C++03 parentheses initializers

makes the problem go away.



Bug is also reproducible on trunk@195009 configured with ./configure

--enable-languages=c,c++ --prefix=...

Reply via email to