]> git.ipfire.org Git - thirdparty/gcc.git/commit
Redefine NULL to nullptr
authorIlya Leoshkevich <iii@linux.ibm.com>
Mon, 29 Jun 2020 18:36:03 +0000 (20:36 +0200)
committerGiuliano Belinassi <giuliano.belinassi@usp.br>
Mon, 17 Aug 2020 16:15:53 +0000 (13:15 -0300)
commit6718e73ce186053cb77bf87b25cd2224d49e4a5f
tree1f9af45298c0b5d052541538ca3e58069c84abe1
parent840f0fa6d94b18e50ef58c1531940e53abe71527
Redefine NULL to nullptr

Bootstrap with musl libc fails with numerous "missing sentinel in
function call" errors.  This is because musl defines NULL as 0L for C++,
but gcc requires sentinel value to be a pointer or __null.

Jonathan Wakely says:

    To be really safe during stage 1, GCC should not use NULL as a
    pointer sentinel in C++ code anyway.

    The bootstrap compiler could define it to 0 or 0u, neither of which
    is guaranteed to be OK to pass as a varargs sentinel where a null
    pointer is expected.  Any of (void*)0 or (void*)NULL or nullptr
    would be safe.

While it is possible to fix this by replacing NULL sentinels with
nullptrs, such approach would generate backporting conflicts, therefore
simply redefine NULL to nullptr at the end of system.h, where it would
not confuse system headers.

gcc/ChangeLog:

2020-06-30  Ilya Leoshkevich  <iii@linux.ibm.com>

PR bootstrap/95700
* system.h (NULL): Redefine to nullptr.
gcc/system.h