Emptyness vs. virtualness
Martin von Loewis
loewis at informatik.hu-berlin.de
Thu Mar 22 08:54:22 UTC 2001
> But that's what I would have expected. The rule is that we first lay out
> the non-virtual things (C (not B), A2 (with A)) and then all the virtual
> bases (B). By the time we get to B, it's A can't be at 0, so we get a new
> one.
In 2.4-III, there is a statement
# Any indirect primary base class E of the current class C, that has
# been chosen as the primary base class of some other base class
# (direct or indirect, virtual or non-virtual) of C, will be allocated
# as part of that other base class, and is not allocated here.
Copying Mark's example again
struct A {};
struct B : public A {
virtual void f () {}
};
struct C : public virtual B {};
struct A2 : public A {};
struct D : public C, public A2 {
};
I find that B is the primary base of C, right? Now, I put C at offset
0 of D, as the primary base of D. Since B is an "indirect primary
base" of D, it will be allocated as part of C.
So I would say that C, with B and A, go at offset 0. Then, A2 cannot
go to offset 0.
Regards,
Martin
More information about the cxx-abi-dev
mailing list