c++/9438: type component conflict shown in class layout.

yanliu@ca.ibm.com yanliu@ca.ibm.com
Sat Jan 25 12:06:00 GMT 2003


>Number:         9438
>Category:       c++
>Synopsis:       type component conflict shown in class layout.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 25 04:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     yan liu
>Release:        gnu c++ version 3.2
>Organization:
>Environment:

>Description:
/*********test.C ********/
struct A{};
struct B: public virtual A
{
virtual void f();
};
struct C: public virtual A, public B
{
int a;
};
void B::f() {}

int main()
{
C c;
}
/**************/
According to ABI, when mapping virtual empty bases, we should to check for  type component confliction first. Here in the testcase, the virtual empty base A resides at the same offset with another non-virtual empty base A.
>How-To-Repeat:
g++ -fdump-class-hierarchy test.C
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test.C.class"
Content-Disposition: inline; filename="test.C.class"

Class A
   size=1 align=1
A (0x40092240) 0 empty

Vtable for B
B::_ZTV1B: 4 entries
0     0
4     0
8     &_ZTI1B
12    B::f()

VTT for B
B::_ZTT1B: 1 entries
0     ((&B::_ZTV1B) + 12)

Class B
   size=4 align=4
B (0x40092580) 0 nearly-empty
    vptridx=0 vptr=((&B::_ZTV1B) + 12)
  A (0x400925c0) 0 empty virtual canonical
      vbaseoffset=-12

Vtable for C
C::_ZTV1C: 4 entries
0     0
4     0
8     &_ZTI1C
12    B::f()

Construction vtable for B (0x40092c40 instance) in C
C::_ZTC1C0_1B: 4 entries
0     0
4     0
8     &_ZTI1B
12    B::f()

VTT for C
C::_ZTT1C: 2 entries
0     ((&C::_ZTV1C) + 12)
4     ((&C::_ZTC1C0_1B) + 12)

Class C
   size=8 align=4
C (0x40092bc0) 0
    vptridx=0 vptr=((&C::_ZTV1C) + 12)
  A (0x40092c00) 0 empty virtual canonical
      vbaseoffset=-12
  B (0x40092c40) 0 nearly-empty
      primary-for C (0x40092bc0)
      subvttidx=4
    A (0x40092c80) 0 empty virtual non-canonical



More information about the Gcc-bugs mailing list