This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2119. Disambiguation of multi-level covariant return type

Section: 11.7.3  [class.virtual]     Status: NAD     Submitter: David Majnemer     Date: 2015-05-05

In an example like

  struct W {};
  struct X : W {};
  struct Y : W {};
  struct Z : X, Y {}; // Z has two W subobjects

  struct A {
    virtual W *f();
  struct B : A {
    virtual X *f();
  struct C : B {
    virtual Z *f();   // C::f overrides A::f and B::f

it is not clear whether the return type of C::f() satisfies the requirement of 11.7.3 [class.virtual] bullet 7.2 that the return type in the base class of the function be an unambiguous base of the return type in the derived class. Should the conversion from Z* to X* in overriding B::f() be considered to disambiguate the conversion from Z* to W* in overriding A::f()? There is implementation divergence on this question.

Rationale (May, 2015):

CWG determined that the current wording of the Standard is correct: C::f() overrides both B::f() and A::f(), and the latter overriding is ill-formed because of the ambiguity.