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


2907. Constant lvalue-to-rvalue conversion on uninitialized std::nullptr_t

Section: 7.7  [expr.const]     Status: DR     Submitter: Jim X     Date: 2023-01-10

[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: