This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
There is implementation variance in the treatment of the following example:
constexpr int f(int x) { return x; } int main() { struct { int x = f(x = 37); } constexpr a = { }; }
Is the assignment to x considered to satisfy the requirememts of 7.7 [expr.const] bullet 2.17,
modification of an object (7.6.19 [expr.ass], 7.6.1.6 [expr.post.incr], 7.6.2.3 [expr.pre.incr]) unless it is applied to a non-volatile lvalue of literal type that refers to a non-volatile object whose lifetime began within the evaluation of e;
assuming that e is the full-expression encompassing the initialization of a?
Notes from the October, 2018 teleconference:
This kind of example was previously ill-formed but it was inadvertently allowed by the change to the “non-vacuous initialization” rule. That rule should be restricted to class and array types, making this example again ill-formed.
Rationale, February, 2021:
The resolution of 2256 makes clear that the lifetime of x has not begun because its initialization is not yet complete, so the assignment is undefined behavior and thus ill-formed in a constant expression.