Title
Disambiguation of multi-level covariant return type
Status
nad
Section
11.7.3 [class.virtual]
Submitter
David Majnemer

Created on 2015-05-05.00:00:00 last changed 108 months ago

Messages

Date: 2015-05-15.00:00:00

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.

Date: 2022-11-20.07:54:16

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.

History
Date User Action Args
2015-05-25 00:00:00adminsetmessages: + msg5963
2015-05-05 00:00:00admincreate