This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.
NULL
and nullptr
Section: 17.2 [support.types] Status: NAD Submitter: Sean Hunt Opened: 2010-02-07 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [support.types].
View all issues with NAD status.
Discussion:
Currently, the 17.2 [support.types]/3 allows NULL
to be any
null pointer constant. The footnote marks that 0 or 0L might be appropriate.
However, this definition also allows the implementation to define NULL
to be nullptr
. This may lead to overload and conversion issues more
serious than with the C++98 version:
void f(void*); void f(int); void g() { // calls f(int) if NULL is integral // calls f(void*) if NULL is nullptr f(NULL); }
Possible resolutions:
NULL
from being nullptr
NULL
to be nullptr
Making NULL
nullptr
would improve code correctness, and
breaking backwards compatibility shouldn't be a huge concern as NULL
shouldn't be used except as a null pointer constant anyways.
[ 2010-02-10 Chris provided wording. ]
[ 2010 Pittsburgh: Moved to NAD, rationale added below. ]
Rationale:
The LWG discussed the proposed resolution and several other options. There was no concensus to make this or any other changes.
Proposed resolution:
17.2 [support.types]
3 The macro
NULL
is defined to benullptr
.is an implementation-defined C++ null pointer constant in this International Standard (4.10).196
196) Possible definitions include0
and0L
, but not(void*)0
.
20.2.12 [c.malloc]
7 The contents are the same as the Standard C library header
<string.h>
, with the change tomemchr()
specified in 21.6 and the macroNULL
defined to benullptr
.
[date.time]
2 The contents are the same as the Standard C library header
<time.h>
.232 except the macroNULL
, which is defined to benullptr
. The functionsasctime
,ctime
,gmtime
, andlocaltime
are not required to avoid data races (17.6.4.8).
28.3.5 [c.locales]
2 The contents are the same as the Standard C library header
<locale.h>
except the macroNULL
, which is defined to benullptr
.
C.8.3.7 [diff.null]
1 The macro
NULL
, defined in any of<clocale>
,<cstddef>
,<cstdio>
,<cstdlib>
,<cstring>
,<ctime>
, or<cwchar>
, is nullptran implementation-defined C++ null pointer constant in this International Standard (18.2).