Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


2310. Type completeness and derived-to-base pointer conversions

Section:7.3.12  [conv.ptr]    Status:CD5    Submitter:Richard Smith    Date:2016-08-08

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

The specification of derived-to-base pointer conversions in7.3.12 [conv.ptr] paragraph 3 does not require that the derivedclass be complete at the point of the conversion. This leaves unclear thestatus of an example like the following, on which there is implementationdivergence:

  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  };

Notes from the March, 2018 meeting:

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

Proposed resolution (November, 2018):

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

  2. A prvalue of type “pointer tocvD”, whereD is acompleteclass type, can be converted to a prvalue of type“pointer tocvB”, whereB is a base class(11.7 [class.derived]) ofD. IfB isan inaccessible...
  3. Change 7.3.13 [conv.mem] paragraph 2 as follows:

  4. A prvalue of type “pointer to member ofB oftypecvT”, where B is aclass type, can be converted to a prvalue of type“pointer to member ofD of typecvT”, whereDis acomplete classderivedclass(11.7 [class.derived])offromB. IfBis an inaccessible...
  5. Change 7.6.1.9 [expr.static.cast] paragraphs 11 and 12 asfollowed:

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

    A prvalue of type “pointer to member ofDof typecv1T” can be converted to a prvalue of type“pointer to member ofBof typecv2T”, whereBis a base class (11.7 [class.derived]) ofa complete classD, ifcv2is the same...




[8]ページ先頭

©2009-2026 Movatter.jp