Created on 2023-01-10.00:00:00 last changed 3 months ago
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.10.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;
- ...
[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.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-09-12 22:42:26 | admin | set | status: open -> cd7 |
| 2025-09-12 22:42:26 | admin | set | status: drwp -> open |
| 2025-04-13 20:07:31 | admin | set | status: dr -> drwp |
| 2024-12-17 09:54:02 | admin | set | status: ready -> dr |
| 2024-11-19 12:01:24 | admin | set | status: tentatively ready -> ready |
| 2024-10-11 20:31:34 | admin | set | messages: + msg7836 |
| 2024-10-11 20:31:34 | admin | set | status: open -> tentatively ready |
| 2023-01-10 00:00:00 | admin | create | |