Created on 2025-03-26.00:00:00 last changed 1 week ago
Possible resolution:
Change in 7.7 [expr.const] paragraph 16 as follows, also amending the example:
During the evaluation of an expression E as a core constant expression, all id-expressions, splice-expressions, and uses of *this that refer to an object or reference whoselifetimeinitialization did not begin within the evaluation of E are treated as referring to a specific instance of that object or reference whose lifetime and that of all subobjects (including all union members) includes the entire constant evaluation. ...constexpr int f() { int& x = x; // #1 return 1; } constexpr int wat = f(); // error: not a constant expression due to #1-- end example ]
(From submission #846.)
Consider:
constexpr int f() {
int &x = x;
return 1;
}
constexpr int wat = f();
According to 7.7 [expr.const] paragraph 16, this is valid, because x is constexpr-unknown within the initializer of x.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-02-27 07:53:26 | admin | set | messages: + msg8494 |
| 2025-03-26 00:00:00 | admin | create | |