Title
Type completeness and derived-to-base pointer conversions
Status
cd5
Section
7.3.12 [conv.ptr]
Submitter
Richard Smith

Created on 2016-08-08.00:00:00 last changed 7 months ago

Messages

Date: 2018-11-15.00:00:00

Proposed resolution (November, 2018):

  1. Change 7.3.12 [conv.ptr] paragraph 3 as follows:

  2. A prvalue of type “pointer to cv D”, where D is a complete class type, can be converted to a prvalue of type “pointer to cv B”, where B is a base class (11.7 [class.derived]) of D. If B is an inaccessible...
  3. Change 7.3.13 [conv.mem] paragraph 2 as follows:

  4. A prvalue of type “pointer to member of B of type cv T”, where B is a class type, can be converted to a prvalue of type “pointer to member of D of type cv T”, where D is a complete class derived class (11.7 [class.derived]) of from B. If B is an inaccessible...
  5. Change 7.6.1.9 [expr.static.cast] paragraphs 11 and 12 as followed:

  6. A prvalue of type “pointer to cv1 B”, where B is a complete class type, can be converted to a prvalue of type “pointer to cv2 D”, where D is a class derived (11.7 [class.derived]) from B , if cv2 is the same...

    A prvalue of type “pointer to member of D of type cv1 T” can be converted to a prvalue of type “pointer to member of B of type cv2 T”, where B is a base class (11.7 [class.derived]) of a complete class D, if cv2 is the same...

Date: 2018-03-15.00:00:00

Notes from the March, 2018 meeting:

The consensus of CWG was that the derived class must be complete at the point of the conversion, and thus all three attempted conversions in the example are ill-formed.

Date: 2019-02-15.00:00:00

[Accepted as a DR at the February, 2019 meeting.]

The specification of derived-to-base pointer conversions in 7.3.12 [conv.ptr] paragraph 3 does not require that the derived class be complete at the point of the conversion. This leaves unclear the status of an example like the following, on which there is implementation divergence:

  template<typename A, typename B> struct check_derived_from { 
    static A a; 
    static constexpr B *p = &a; 
  }; 
  struct W {}; 
  struct X {}; 
  struct Y {}; 
  struct Z : W, 
    X, check_derived_from<Z, X>,  // #1 
    check_derived_from<Z, Y>, Y { // #2 
    check_derived_from<Z, W> cdf; // #3 
  }; 
History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6373
2020-12-15 00:00:00adminsetstatus: drafting -> cd5
2018-04-11 00:00:00adminsetmessages: + msg6190
2018-04-11 00:00:00adminsetstatus: open -> drafting
2016-08-08 00:00:00admincreate