empty base packing strategy

Jim Dehnert dehnert at baalbek.engr.sgi.com
Wed Jul 21 00:27:57 UTC 1999


> Date: Thu, 15 Jul 1999 04:04:57 -0700
> From: Jason Merrill <jason at cygnus.com>
> 
> Say we have an A subobject, AO, followed by a B subobject.  If A ends with
> an empty class subjobject and B begins with an object of the same type, add
> 1 to the size of AO for layout purposes.

Perhaps I'm coming into the middle of something with context from the
meetings I missed, but this seems like a confusing way to look at this.
First, A should have a well-defined size, and second, it leads to
questions about how to handle more general cases.  Consider Daveed's
earlier example:

        struct E1 { };
        struct E2: E1 { };
        struct E3 { };
        struct E4: E3 { };
        struct N1 { E1 n1; }

        struct D: E1, E2, N1, E3, E4 {
          E3 e3;
        };

As we saw, this struct has a "size" somewhere between 3 and 6 bytes
(depending on your interpretation of the layout rules), assuming that
any object has a non-zero size (as required by the Standard), and all
members must be "inside" the containing object.  However, I think we
can (and should if it's not too difficult) view it all as tail padding.

Now, if this (D) is the A0 subobject of Jason's statement, where do we
put B?  My interpretation of our decision three weeks ago is that we
attempt to put it at the beginning of the tail padding, i.e.
potentially at the beginning of A0.  If that fails because of a
type-at-same-offset conflict, then you try the next available (based
on alignment constraints) offset, then the next, etc.  That is, just
increment the offset you consider for B directly -- don't do it
implicitly by talking about modifying the size of A.

-	    Jim Dehnert		dehnert at sgi.com
				(650)933-4272




More information about the cxx-abi-dev mailing list