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.

### 1314. `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:

- Forbid `NULL` from being `nullptr`
- Require `NULL` to be `nullptr`
- Leave it as is

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 be `nullptr`. is an implementation-defined C++ null pointer constant in this International Standard (4.10).196

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

20.10.11 [c.malloc]

> 7 The contents are the same as the Standard C library header `<string.h>`, with the change to `memchr()` specified in 21.6 and the macro `NULL` defined to be `nullptr`.

[date.time]

> 2 The contents are the same as the Standard C library header `<time.h>`.232 except the macro `NULL`, which is defined to be `nullptr`. The functions `asctime`, `ctime`, `gmtime`, and `localtime` are not required to avoid data races (17.6.4.8).

28.5 [c.locales]

> 2 The contents are the same as the Standard C library header `<locale.h>` except the macro `NULL`, which is defined to be `nullptr`.

C.7.3.7 [diff.null]

> 1 The macro `NULL`, defined in any of `<clocale>`, `<cstddef>`, `<cstdio>`, `<cstdlib>`, `<cstring>`, `<ctime>`, or `<cwchar>`, is nullptr an implementation-defined C++ null pointer constant in this International Standard (18.2).