Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -286,8 +286,12 @@ #endif #if !(__has_feature(cxx_nullptr)) +#if !(__is_identifier(__nullptr)) +#define nullptr __nullptr +#else #define _LIBCPP_HAS_NO_NULLPTR #endif +#endif #if !(__has_feature(cxx_rvalue_references)) #define _LIBCPP_HAS_NO_RVALUE_REFERENCES Index: test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp =================================================================== --- test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp +++ test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp @@ -7,12 +7,22 @@ // //===----------------------------------------------------------------------===// -// NOTE: nullptr_t emulation cannot handle a reinterpret_cast to an -// integral type -// XFAIL: c++98, c++03 - // typedef decltype(nullptr) nullptr_t; +// C++ standard: +// 5.2.10 Reinterpret cast [expr.reinterpret.cast] +// p4. A pointer can be explicitly converted to any integral type large enough +// to hold it. The mapping function is implementation-defined. [ Note: It is +// intended to be unsurprising to those who know the addressing structure of +// the underlying machine. — end note ] A value of type std::nullptr_t can be +// converted to an integral type; the conversion has the same meaning and +// validity as a conversion of (void*)0 to the integral type. +// [ Note: A reinterpret_cast cannot be used to convert a value of any type +// to the type std::nullptr_t.— end note ] + +// NOTE: libc++ provides nullptr_t emulation when 'nullptr' is not provided by +// the compiler. However there is no way to emulate the reinterpret_cast. +// UNSUPPORTED: C++98, C++03 #include #include