|October 15, 2002|
|Crazy ABI Layout Rules|
A couple of years ago, EDG was invited to participate in the development of an ABI (Application Binary Interface) for C++ on the Itanium architecture. The weekly development meetings ocurred in the Bay Area (SGI facilities), and since I lived close to there at the time, I represented EDG.
I hear you say “But what about templates?” Good reflex, but forget about those for now. Instead, let me rant about a more basic topic: Laying out subobjects in memory.
An object of type D contains three direct subobjects: a field i and two base subobjects (of types B1 and B2 respectively). Most of the time, each of these subobjects take up some bytes of memory within the sizeof(D) bytes occupied by D. One exception is that if a base class type is “empty” it may be optimized not to take up any space at all. Still, an optimized empty base class (OEBC) must have its own address.
then the base subobject of type B2 ends up inside the field of type int.