This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
[Accepted as a DR at the November, 2024 meeting.]
(From submission #215.)
Consider:
void f() { std::nullptr_t np; // uninitialized, thus np contains an erroneous value constexpr void *p1 = np; // error: converted initializer is not a constant expression }
The lvalue-to-rvalue conversion on np does not actually read the value of np (7.3.2 [conv.lval] bullet 3.1), yet the situation is made ill-formed by 7.7 [expr.const] bullet 5.9.
Proposed resolution (approved by CWG 2024-10-11):
Change in 7.7 [expr.const] bullet 5.9 as follows:
An expression E is a core constant expression unless the evaluation of E, following the rules of the abstract machine (6.9.1 [intro.execution]), would evaluate one of the following:
- ...
- an lvalue-to-rvalue conversion (7.3.2 [conv.lval]) unless it is applied to
- a glvalue of type cv std::nullptr_t,
- a non-volatile glvalue that refers to an object that is usable in constant expressions, or
- a non-volatile glvalue of literal type that refers to a non-volatile object whose lifetime began within the evaluation of E;
- ...