https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93543

Sebastian Huber <sebastian.hu...@embedded-brains.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sebastian.huber@embedded-br
                   |                            |ains.de

--- Comment #2 from Sebastian Huber <sebastian.hu...@embedded-brains.de> ---
LLVM 8.0.1 is also affected by this. In

https://en.cppreference.com/w/cpp/language/reinterpret_cast

I found this note:

"9) The null pointer value of any pointer type can be converted to any other
pointer type, resulting in the null pointer value of that type. Note that the
null pointer constant nullptr or any other value of type std::nullptr_t cannot
be converted to a pointer with reinterpret_cast: implicit conversion or
static_cast should be used for this purpose."

Consider the following test program:

struct function;

function *g(void)
{
  return static_cast<function *>(nullptr);
}

function *f(void)
{
  return reinterpret_cast<function *>(nullptr);
}

$ clang -c test.cc
test.cc:10:10: error: reinterpret_cast from 'nullptr_t' to 'function *' is not
allowed
  return reinterpret_cast<function *>(nullptr);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Reply via email to