Vtable index type

Jason Merrill jason at cygnus.com
Tue Feb 22 23:46:11 UTC 2000


>>>>> Mark Mitchell <mark at codesourcery.com> writes:

>>>>> "Jason" == Jason Merrill <jason at cygnus.com> writes:
>>>>> Mark Mitchell <mark at codesourcery.com> writes:

 >>> We should specify a type for vtable indices.  It seems to me
 >>> that `ptrdiff_t' is the obvious candidate.

 >>> This is important in that it limits the number of vtable
 >>> entries we can use.  (For example, g++ has historically used
 >>> `short' for a vtable index; that limited the size of vtables.)

 Jason> Where does a vtable index appear in the ABI?

 > Pointers-to-members.

Actually, that's an offset (in bytes), not an index (in slots).  I suppose
we should define "vtable offset" somewhere.  But the same issue applies.

 > Suppose we check the `ptr' field, and notice it's odd.  Now, we have to
 > divide by two and use the resulting thing as a vtable index.  If, say,
 > we only allowed n-bit indices, then we could shift right one bit, and
 > pull out just the low-order n-bits.  I don't know *why* anyone would
 > want to do that, but the ABI should say whether or not its legal to do
 > so.

Makes sense.  I agree that ptrdiff_t seems like the obvious resolution.

Jason




More information about the cxx-abi-dev mailing list