[libcxx] r290662 - Fix ABI incompatible C++03 nullptr_t

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 28 01:50:25 PST 2016

Author: ericwf
Date: Wed Dec 28 03:50:23 2016
New Revision: 290662

URL: http://llvm.org/viewvc/llvm-project?rev=290662&view=rev
Fix ABI incompatible C++03 nullptr_t

In C++03 libc++ emulates nullptr_t using a class, and #define's nullptr.
However this makes nullptr_t mangle differently between C++03 and C++11.
This breaks any function ABI which takes nullptr_t.

Thanfully Clang provides __nullptr in all dialects. This patch adds
an ABI option to switch to using __nullptr in C++03. In a perfect world
I would like to turn this on by default, since it's just ABI breaking fix
to an ABI breaking bug.


Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290662&r1=290661&r2=290662&view=diff
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Dec 28 03:50:23 2016
@@ -48,6 +48,10 @@
+// Don't use a nullptr_t simulation type in C++03 and use theh C++11 nullptr
+// provided under the alternate keyword __nullptr, which changes the mangling
+// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
 // Feature macros for disabling pre ABI v1 features. All of these options
 // are deprecated.
@@ -266,7 +270,11 @@ typedef __char32_t char32_t;
 #if !(__has_feature(cxx_nullptr))
+# if __has_extension(cxx_nullptr) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
+#   define nullptr __nullptr
+# else
+# endif
 #if !(__has_feature(cxx_rvalue_references))

More information about the cfe-commits mailing list