Title
Constant lvalue-to-rvalue conversion on uninitialized std::nullptr_t
Status
dr
Section
7.7 [expr.const]
Submitter
Jim X

Created on 2023-01-10.00:00:00 last changed 4 days ago

Messages

Date: 2024-10-11.20:31:34

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;
  • ...
Date: 2024-11-15.00:00:00

[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
2024-12-17 09:54:02adminsetstatus: ready -> dr
2024-11-19 12:01:24adminsetstatus: tentatively ready -> ready
2024-10-11 20:31:34adminsetmessages: + msg7836
2024-10-11 20:31:34adminsetstatus: open -> tentatively ready
2023-01-10 00:00:00admincreate