Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Thu, 23 Dec 2021 20:28:28 -0500
From: Rich Felker <>
To: Colin Cross <>
Cc:, Ismael Luceno <>
Subject: Re: Re: [PATCH] Define NULL as nullptr when used in C++

On Thu, Dec 23, 2021 at 04:05:22PM -0500, Rich Felker wrote:
> On Thu, Dec 23, 2021 at 11:13:01AM -0800, Colin Cross wrote:
> > On Sun, Aug 15, 2021 at 05:51:57PM +0200, Ismael Luceno wrote:
> > > This should be safer for casting and more compatible with existing code
> > > bases that wrongly assume it must be defined as a pointer.
> > 
> > This seems to meet the C++ spec for NULL [1], but I noticed some
> > compatibility issues with code that was previously compiling with
> > glibc.
> > 
> > I've found multiple places that used reinterpret_cast<int*>(NULL),
> > which now fail with:
> > error: reinterpret_cast from 'nullptr_t' to 'int *' is not allowed
> > According to [2] those should technically be static_cast and not
> > reinterpret_cast.
> This is an improvement then. reinterpret_cast is very very wrong here
> and should produce a compile error. It's the equivalent of writing (in
> C):
> 	*(int **)&(void *){NULL}
> instead of
> 	(int *)NULL
> i.e. it's type punning where the author intended a value conversion.

I've been informed I'm probably wrong about this, because
reinterpret_cast means something different when applied to pointers
than to other types. Still, getting the error is right as far as I can
tell, since reinterpret_cast is not supposed to accept nullptr_t for
conversion to int*.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.