Typo in data layout document
Mark Mitchell
mark at codesourcery.com
Sun Apr 2 03:18:58 UTC 2000
Under virtual base allocation:
Any indirect primary base class E of the current class C, 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.
That's not a sentence. :-) There should be a `that' before `has been
chosen'.
I think it would be useful to note the following example near that
paragraph. (The C++ standard contains examples intermixed with the
rules, and it makes it much easier to read.)
Consider:
struct R { virtual void r (); };
struct S { virtual void s (); };
struct T : virtual public S { virtual void t (); };
struct U : public R, virtual public T { virtual void u (); };
R is the primary base class for U since it is the first direct
non-virtual dynamic base. Then, since an inheritance-order walk of
U is { U, R, T, S } the T base is allocated next. Since S is a
primary base of T, there is no need to allocate it separately.
However, given:
struct V : public R, virtual public S, virtual public T {
virtual void v ();
};
the inheritance-order walk of V is { V, R, S, T } so S is allocated
first as a virtual base. Then, T is allocated separately. Thus
sizeof (V) > sizeof (U).
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the cxx-abi-dev
mailing list