Covariant return clarification
Mark Mitchell
mark at codesourcery.com
Fri Jan 3 21:06:07 UTC 2003
The ABI specification, at present, implies that given
struct A {};
struct B : public A {};
struct X {
virtual A* f();
};
struct Y : public X {
virtual B* f();
};
Y::f is to be considered covariant with respect to X::f, i.e., that
"B*" and "A*" are "substantively different".
This is an oversight; clearly there is no conversion required to
convert form B* to A* and there is therefore no need for a thunk in
that situation.
I've improved the wording below.
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
Index: abi.html
===================================================================
RCS file: /usr/local/Repository/cxx-abi/abi.html,v
retrieving revision 1.58
diff -c -5 -p -r1.58 abi.html
*** abi.html 31 Dec 2002 19:56:24 -0000 1.58
--- abi.html 3 Jan 2003 18:21:32 -0000
*************** two conditions holds:
*** 1250,1261 ****
in the virtual table, but the return type of the overrider is
substantively different from the return type of the function(s)
already present. If the return types are different, they are
both pointer-to-class types, or both reference-to-class types.
Let B and D denote the classes, where D is derived from B. The
! types are substantively different if B is a virtual base or is
! not an indirect primary base of D.
</ul>
<p>
<img src=warning.gif alt="<b>NOTE</b>:">
<i>
--- 1250,1261 ----
in the virtual table, but the return type of the overrider is
substantively different from the return type of the function(s)
already present. If the return types are different, they are
both pointer-to-class types, or both reference-to-class types.
Let B and D denote the classes, where D is derived from B. The
! types are substantively different if B is a morally virtual base of D
! or if B is not located at offset zero in D.
</ul>
<p>
<img src=warning.gif alt="<b>NOTE</b>:">
<i>
*************** unwind table location.
*** 4939,4948 ****
--- 4939,4952 ----
<p> <hr> <p>
<a name=revisions>
<h2> Appendix R: Revision History </h2>
<p> <hr> <p>
+
+ <p>
+ <font color=blue>[030103]</font>
+ Clarify definition of substantively different types.
<p>
<font color=blue>[021222]</font>
Document mangling for anonymous unions.
More information about the cxx-abi-dev
mailing list