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

           Summary: Incorrect construction vtable on ARM in case of
                    diamond shaped virtual inheritance
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: end...@gmail.com


Created attachment 22295
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22295
Code that triggers the issue on ARM

This problem appears on ARM (not x86), with -O > 0.

The register R1 holding the pointer to the construction vtable for the
Parent-in-Child is actually pointing to the wrong Parent-in-Child vtable:

Let's assume we have a virtual base class A, two derived class B and C
virtually inheriting from A and a final class D derived virtually from B and
normally from C.

When instantiating D, the CTOR for B is called with R1 pointing to the
construction vtable for B-in-D instead of the one for C-in-D, which thus make
the program crash since it tries to access an uninitialized element of the
vtable for B when trying to access elements in C. 

A work-around for this issue is to compile with -fno-toplevel-reorder. It fixes
the problem for all optimizations level

This issue seems to be linked to #41354.

Reply via email to