[PATCH] D73245: Don't define std::max_align_t if not used in C++03 mode

Joerg Sonnenberger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 17:23:12 PST 2020


joerg created this revision.
joerg added a reviewer: mclow.lists.
Herald added a subscriber: christof.

max_align_t has been introduced by C++11 and C99. When an older language mode is explicitly requested, the system headers might not provide. Don't define it in this case unless other headers (<new>) depend on it.


https://reviews.llvm.org/D73245

Files:
  libcxx/include/cstddef


Index: libcxx/include/cstddef
===================================================================
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -49,6 +49,9 @@
 using ::ptrdiff_t;
 using ::size_t;
 
+// max_align_t is part of C99/C++11, but necessary for <new>
+// if the compiler doesn't tell us the default new alignment.
+#if !defined(_LIBCPP_CXX03_LANG) || !defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
 #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
     defined(__DEFINED_max_align_t) || defined(__NetBSD__)
 // Re-use the compiler's <stddef.h> max_align_t where possible.
@@ -56,6 +59,7 @@
 #else
 typedef long double max_align_t;
 #endif
+#endif
 
 _LIBCPP_END_NAMESPACE_STD
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73245.239742.patch
Type: text/x-patch
Size: 720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200123/267cab7c/attachment.bin>


More information about the llvm-commits mailing list