[C++ PATCH] covariant abi conformance

Nathan Sidwell nathan@codesourcery.com
Tue Jan 28 09:18:00 GMT 2003


Jason Merrill wrote:
> On Mon, 27 Jan 2003 23:38:34 +0000, Nathan Sidwell <nathan@codesourcery.com> wrote:
> 
> 
>>When a thunk overrides something from a virtual primary base, we know the
>>adjustment will be zero. For plain this adjusting thunks, we just reference
>>the base function, no adjustment being necessary. But for covariant overrides
>>we must emit a thunk. The simple solution to reference a thunk with a fixed
>>zero adjustment is wrong, because the ABI gives no mangling for that. As we
>>don't know whether the compiler generating the vtable and that compiling the
>>base-function (and therefore emitting all the thunks) will be the same (i.e.
>>us), we have to do what the ABI says, and actually reference a vcall adjusting
>>thunk which will adjust by zero.
> 
> 
> We may need to emit such a thunk, but I don't think we need to refer to it
> in the vtable.
I presume you're refering to the vcall-adjusting covariant thunk. What you say
is what I originally thought, but it is not what the ABI says. (Thanks
to Jeffrey for reading what it really says.)
5.1.4 of the abi says,
	Virtual function override thunks come in two forms. Those overriding
	from a non-virtual base, with fixed this adjustments, use a "Th" prefix
	and encode the required adjustment offset, probably negative, indicated
	by a 'n' prefix, and the encoding of the target function. ***Those
	overriding from a virtual base must encode two offsets after a "Tv"
	prefix.***

When a covariant thunk overides something from a virtual primary base, that
last sentance applies (unfortunately).
3.2.3 says what thunks must be emitted with the overriding function. It talks
only about this-adjusting thunks. What it does *not* say is 'for covariant thunks
overriding (lost or nonlost) virtual primary bases, emit a covariant thunk with
no this adjustment', which is what we'd need.


nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
          The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org




More information about the Gcc-patches mailing list