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.

4182. Definition of NULL is too broad

Section: 17.2.3 [support.types.nullptr] Status: New Submitter: Janet Cobb Opened: 2024-12-09 Last modified: 2024-12-21

Priority: Not Prioritized

View all issues with New status.

Discussion:

7.3.12 [conv.ptr]/1 reads in part: "A null pointer constant is an integer literal (5.13.2 [lex.icon]) with value zero or a prvalue of type std::nullptr_t.".

17.2.3 [support.types.nullptr]/2 reads: "The macro NULL is an implementation-defined null pointer constant.".

Together, these imply that #define NULL (::std::unreachable(), nullptr) is a conforming definition. The expression is a prvalue of type std::nullptr_t, so it is a null pointer constant. This makes it implementation-defined whether any program that evaluates NULL has undefined behavior.

Proposed resolution:

This wording is relative to N5001.

  1. Modify 17.2.3 [support.types.nullptr] as indicated:

    -2- The macro NULL is an implementation-defined null pointer constant that is a literal (5.13.2 [lex.icon], 5.13.8 [lex.nullptr]).footnote 161

    161) Possible definitions include 0 and 0L, but not (void*)0.