Emptyness vs. virtualness

Mark Mitchell mark at codesourcery.com
Wed Mar 21 20:19:17 UTC 2001


I have this recollection that when we're laying out a base class, and
we're checking for overlapping empty objects with the same type, that
we agreed not to look at *virtual* bases.

Concretely, consider:

  struct A {};

  struct B : public A {
    virtual void f () {}
  };

  struct C : public virtual B {};

  struct A2 : public A {};

  struct D : public C, public A2 {
  };

Clearly C goes at offset 0.  Now, can A2 go at offset 0?  If it does,
then there is an A overlap -- if you consider C's virtual bases, but
not if you don't.  And, we haven't allocated virtual bases yet.

The ABI document just says "direct or indirect bases", which I read as
saying that A2 *cannot* go at offset zero.

We have a disagreement between two of our implementations; I'm trying
to figure out if we actually decided this before or not.  Does anyone
recall any traffic about this?

Thanks,

--
Mark Mitchell                   mark at codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com





More information about the cxx-abi-dev mailing list