Vtable index type

Jim Dehnert dehnert at baalbek.engr.sgi.com
Tue Feb 29 05:04:59 UTC 2000


> From: Jason Merrill <jason at cygnus.com>
> 
>  >>> 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.

I've added this to the description of ptr in the Member Pointers
section of the layout document.  So unless anyone objects to this
resolution, we'll consider it done.

NOTE:  I also fixed the description to remove the "multipled by two"
part, since we had agreed not do do that (see the closed issues list,
A-11).  I apologize for not transcribing it correctly the first time.

Jim

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




More information about the cxx-abi-dev mailing list