This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4155. Cpp17NullablePointer should require that some expression can be contextually converted to bool

Section: 16.4.4.4 [nullablepointer.requirements] Status: New Submitter: Jiang An Opened: 2024-09-18 Last modified: 2024-10-02

Priority: 3

View all other issues in [nullablepointer.requirements].

View all issues with New status.

Discussion:

Currently, 16.4.4.4 [nullablepointer.requirements]/3 requires "An object p of type P can be contextually converted to bool", while the core language wording (7.3.1 [conv.general]/4) only says some expressions can be contextually converted to bool. Moreover, the value category and cv-qualification are not mentioned, presumably both non-const and const P, together with all value categories are expected.

[2024-10-02; Reflector poll]

Set priority to 3 after reflector poll.

"This is an improvement, but judging from microsoft/STL 4964, I think we actually want to define a "contextually-boolean-testable" for this."

Proposed resolution:

This wording is relative to N4988.

  1. Modify 16.4.4.4 [nullablepointer.requirements] as indicated:

    -3- An object p of type P can be contextually converted to bool. The effect shall be as if p != nullptr had been evaluated in place of p.

  2. Add a row to the bottom of [tab:cpp17.nullablepointer]:

    ExpressionReturn typeOperational semantics
    ... ... ...
    a ? true : false bool a != np