[cfe-dev] Fixing selector types on the GNU runtime
hhinnant at apple.com
Sun Jan 18 16:55:37 CST 2009
On Jan 18, 2009, at 5:12 PM, Sebastian Redl wrote:
> Chris Lattner wrote:
>> On Jan 18, 2009, at 8:14 AM, David Chisnall wrote:
>>> I've also included some fixes in this patch which turn NULL into
>>> (void*)0 when it is used as a sentinel in variadic functions. This
>>> gets rid of a load of warnings when compiling and stops it breaking
>>> on 64-bit architectures.
>> Why are you getting this? There are tons of other places that pass
>> NULL as a sentinel. Is NULL getting defined incorrectly for that
>> file? NULL needs to be a pointer type, so it should be fine on 64-
>> systems. Passing a raw "0" would not be.
> In C++, NULL cannot be a pointer type, because there is no implicit
> from void* to other pointers. So it is usually defined to be 0 or
> 0L. In
> GCC, it's defined to be __null, but that's just 0 with a warning when
> used as an integer.
> So some compiler might be smart enough to convert its __null
> to pointer size when passed as vararg, or to define NULL to an integer
> constant that is actually the platform pointer size (e.g. 0L for GCC,
> but 0LL for MSVC), but I really wouldn't rely on it. The standard
> to specify that NULL must be as wide as a pointer (a defect IMO), so
> can't trust the constant.
> It's one of the most subtle and evil gotchas in C++, really.
nullptr might be one of those C++0X features worth prioritizing.
More information about the cfe-dev