[Development] Oslo, we have a problem</apollo 13> [char8_t]

Thiago Macieira thiago.macieira at intel.com
Sat Jul 6 18:48:55 CEST 2019


On Saturday, 6 July 2019 11:53:13 -03 Mutz, Marc via Development wrote:
> > It can be argued that use of NULL in C++ code is more relict thing and
> > should not be
> > supported. It's also much easier to migrate code base from NULL to
> > nullptr - simple text
> > replacement is enough.
> 
> 0 -> nullptr is just as simple: clang-tidy has a fixit for that.

Not to mention that C++ NULL is not exactly NULL in modern compilers

$ gcc -dM -E -include stddef.h -xc++ /dev/null | grep -w NULL
#define NULL __null
$ clang -dM -E -include stddef.h -xc++ /dev/null | grep -w NULL
#define NULL __null

This internal symbol is an internal type that has special casting properties: 
it does cast to int but it also casts to pointer, such that the following code 
is actually ambiguous with GCC, Clang and ICC (but not MSVC):

	#include <stddef.h>
	void f(const char *);
	void f(int);
	void g() { f(NULL); }
<https://gcc.godbolt.org/z/PTZttz>

So, no, adding an int overload will not help with NULL.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products






More information about the Development mailing list