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

--- Comment #2 from Sun, Chaoyang <wingfire at gmail dot com> 2012-09-16 
11:38:24 UTC ---
(In reply to comment #1)
> The first word contains a pointer to the vtable for X.

If the first word is the vtable of X, the memory layout should be:
{
vptr of x;
data of B;
vptr of A;
}?
but the actual layout is:
{
vptr of X and A
data of B;
}

g++ swapped the memory ordered of A and B.

also,if I have 
struct C{ virtual void foo() {} }; 
and X is defined:

struct X : public B, A,C { };

the actual layout will be:
{
vptr of X and A
data of B;
vptr of C;
}

Is it expected too? If so, it's too difficult to predicate the memory order of
each bases.

Reply via email to