Title
Definition of `NULL` is too broad
Status
new
Section
[support.types.nullptr]
Submitter
Janet Cobb

Created on 2024-12-09.00:00:00 last changed 3 days ago

Messages

Date: 2025-02-07.17:00:32

Proposed resolution:

This wording is relative to N5001.

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

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

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

Date: 2025-02-15.00:00:00

[ 2025-02-07; Jonathan provides improved wording ]

Date: 2025-02-15.00:00:00

[ 2025-02-07; Reflector poll ]

Set priority to 3 after reflector poll.

"I'd very much like to see `nullptr` added to the footnote."

This wording is relative to N5001.

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

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

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

Date: 2024-12-09.00:00:00

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

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

History
Date User Action Args
2025-02-07 17:00:32adminsetmessages: + msg14588
2025-02-07 16:57:42adminsetmessages: + msg14585
2024-12-21 11:01:28adminsetmessages: + msg14523
2024-12-09 00:00:00admincreate