Created on 2012-12-19.00:00:00 last changed 121 months ago
[Moved to DR at the September, 2013 meeting.]
Proposed resolution (August, 2013):
Change 9.2.6 [dcl.constexpr] paragraph 4 as follows:
...In addition, either its function-body shall be = delete, or it shall satisfy the following constraints:
...
for a non-delegating constructor, every constructor
involved in initializingselected to initialize non-static data members and base class sub-objects shall be a constexpr constructor.;for a delegating constructor, the target constructor shall be a constexpr constructor.
According to 9.2.6 [dcl.constexpr] paragraph 5
For a constexpr constructor, if no argument values exist such that after function invocation substitution, every constructor call and full-expression in the mem-initializers would be a constant expression (including conversions), the program is ill-formed; no diagnostic required.
However, paragraph 4 also says,
every constructor involved in initializing non-static data members and base class sub-objects shall be a constexpr constructor;
violation of which requires a diagnostic. The question is whether a constructor call appearing in a mem-initializer expression is “involved in” the initialization of X::m. Given the “no diagnostic required” status of constructor calls in paragraph 5, the intent of the “involved in” phrasing would appear to be referring to constructors of members with class types and of base-class subobjects, but the wording should be clarified. For example, in a constructor definition like
constexpr X(): m(f(S())) { }
if S::S() is not constexpr, is a diagnostic required? For another example,
struct S { constexpr S() {} S(int); }; struct A { S s; }; struct C { A x; constexpr C(): x{ 1 } {} };
Is S::S(int) “involved?”
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-11-24 00:00:00 | admin | set | status: drwp -> c++14 |
2014-03-03 00:00:00 | admin | set | status: dr -> drwp |
2013-10-14 00:00:00 | admin | set | messages: + msg4685 |
2013-10-14 00:00:00 | admin | set | status: tentatively ready -> dr |
2013-09-03 00:00:00 | admin | set | messages: + msg4456 |
2013-09-03 00:00:00 | admin | set | status: drafting -> tentatively ready |
2013-05-03 00:00:00 | admin | set | status: open -> drafting |
2012-12-19 00:00:00 | admin | create |