This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1250. Cv-qualification of incomplete virtual function return types

Section: 11.7.3  [class.virtual]     Status: CD3     Submitter: Jonathan Wakely     Date: 2011-03-03

[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]

According to 11.7.3 [class.virtual] paragraph 8,

If the return type of D::f differs from the return type of B::f, the class type in the return type of D::f shall be complete at the point of declaration of D::f or shall be the class type D.

This provision was intended to deal with covariant return types but inadvertently affects types that vary only in cv-qualification:

    struct A;
    struct B {
        virtual const A* f();
    };
    struct D : B {
        A* f();    // ill-formed
    };

Proposed resolution (August, 2011):

Change 11.7.3 [class.virtual] paragraph 8 as follows:

If the class type in the covariant return type of D::f differs from the return type that of B::f, the class type in the return type of D::f shall be complete at the point of declaration of D::f or shall be the class type D. When the overriding function...