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


1595. Constructors “involved in” subobject initialization

Section:9.2.6  [dcl.constexpr]    Status:C++14    Submitter:Daveed Vandevoorde    Date:2012-12-19

[Moved to DR at the September, 2013 meeting.]

According to 9.2.6 [dcl.constexpr] paragraph 5

For aconstexpr constructor, if no argument values exist such thatafter function invocation substitution, every constructor call andfull-expression in themem-initializers would be a constantexpression (including conversions), the program is ill-formed; nodiagnostic required.

However, paragraph 4 also says,

every constructor involved in initializing non-static data members andbase class sub-objects shall be a constexpr constructor;

violation of which requires a diagnostic. The question is whethera constructor call appearing in amem-initializer expression is“involved in” the initialization ofX::m. Giventhe “no diagnostic required” status of constructor callsin paragraph 5, the intent of the “involved in” phrasingwould appear to be referring to constructors of members with class typesand of base-class subobjects, but the wording should be clarified.For example, in a constructor definition like

  constexpr X(): m(f(S())) { }

ifS::S() is not constexpr, is a diagnostic required? Foranother example,

  struct S {    constexpr S() {}    S(int);  };  struct A { S s; };  struct C {    A x;    constexpr C(): x{ 1 } {}  };

IsS::S(int) “involved?”

Proposed resolution (August, 2013):

Change 9.2.6 [dcl.constexpr] paragraph 4 as follows:

...In addition, either itsfunction-body shall be=delete, or it shall satisfy the following constraints:




[8]ページ先頭

©2009-2026 Movatter.jp