[cfe-dev] Objective-C and C++0x nullptr

David Blaikie dblaikie at gmail.com
Mon May 30 06:48:03 PDT 2011


Indeed NULL can be nullptr, but for backwards compatability reasons
(read: all the things you had to fix after you s/NULL/nullptr/g) it is
unlikely that any practical implementation will do that in the near
future From: Jonathan Sauer
Sent: Monday, May 30, 2011 8:27 AM
To: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] Objective-C and C++0x nullptr
Hello,

>> while naively replacing NULL with nullptr in my code, I stumbled upon the following.
>
> You shouldn't need to do that.  NULL should be a #define for nullptr in C++ 2011 mode, or for something more relevant to the language settings in other modes.

Well, I was trying to initialize a std::unique_ptr with an explicit
NULL, which resulted in an
ambiguity during overload resolution of the constructor (there is one
taking a nullptr_t as well
as one taking a T*). So I took that opportunity to convert this part
of my code base to C++0x,
too (and use std::unique_ptr's default constructor ...).

Clang's behaviour seems to be correct here, as according to FDIS
4.10p1, "0L" can be converted to a
pointer type as well as a std::nullptr_t.

Reading FDIS 18.2p3, it does not seem that NULL is required to be a
#define for nullptr. Indeed, the
footnote there explains that "0" is a valid definition (and libc++
currently uses the system's
stddef.h's definition).


Jonathan


_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list