Index: libcxx/include/cstddef =================================================================== --- libcxx/include/cstddef +++ libcxx/include/cstddef @@ -25,7 +25,7 @@ ptrdiff_t size_t - max_align_t + max_align_t // C++11 nullptr_t byte // C++17 @@ -49,12 +49,8 @@ using ::ptrdiff_t; using ::size_t; -#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \ - defined(__DEFINED_max_align_t) || defined(__NetBSD__) -// Re-use the compiler's max_align_t where possible. +#if !defined(_LIBCPP_CXX03_LANG) using ::max_align_t; -#else -typedef long double max_align_t; #endif template struct __libcpp_is_integral { enum { value = 0 }; }; Index: libcxx/include/new =================================================================== --- libcxx/include/new +++ libcxx/include/new @@ -226,9 +226,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_LIBCPP_CXX03_LANG) +union __libcpp_max_align_t { + void * __f1; + long long int __f2; + long double __f3; +}; +#endif + _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new(size_t __align) _NOEXCEPT { #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__; +#elif defined(_LIBCPP_CXX03_LANG) + return __align > alignment_of<__libcpp_max_align_t>::value; #else return __align > alignment_of::value; #endif Index: libcxx/include/stddef.h =================================================================== --- libcxx/include/stddef.h +++ libcxx/include/stddef.h @@ -51,12 +51,6 @@ using std::nullptr_t; } -// Re-use the compiler's max_align_t where possible. -#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \ - !defined(__DEFINED_max_align_t) && !defined(__NetBSD__) -typedef long double max_align_t; -#endif - #endif #endif // _LIBCPP_STDDEF_H Index: libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp =================================================================== --- libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp +++ libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp @@ -141,7 +141,9 @@ void test_libcpp_dealloc() { void* p = nullptr; +#if TEST_STD_VER >= 11 size_t over_align_val = TEST_ALIGNOF(std::max_align_t) * 2; +#endif size_t under_align_val = TEST_ALIGNOF(int); size_t with_size_val = 2; @@ -151,6 +153,7 @@ } stats.reset(); +#if TEST_STD_VER >= 11 #if defined(NO_SIZE) && defined(NO_ALIGN) { std::__libcpp_deallocate(p, with_size_val, over_align_val); @@ -186,6 +189,7 @@ } stats.reset(); #endif +#endif } struct TEST_ALIGNAS(128) AlignedType { Index: libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp =================================================================== --- libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp +++ libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp @@ -51,7 +51,8 @@ static_assert((std::is_same::value), ""); LIBCPP_ASSERT(p != nullptr); } - { +#if TEST_STD_VER >= 11 + { typedef std::max_align_t T; typedef std::array C; const C c = {}; @@ -60,6 +61,7 @@ std::uintptr_t pint = reinterpret_cast(p); assert(pint % TEST_ALIGNOF(std::max_align_t) == 0); } +#endif { typedef NoDefault T; typedef std::array C; Index: libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp =================================================================== --- libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp +++ libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp @@ -49,6 +49,7 @@ const T* p = c.data(); LIBCPP_ASSERT(p != nullptr); } +#if TEST_STD_VER >= 11 { typedef std::max_align_t T; typedef std::array C; @@ -58,6 +59,7 @@ std::uintptr_t pint = reinterpret_cast(p); assert(pint % TEST_ALIGNOF(std::max_align_t) == 0); } +#endif #if TEST_STD_VER > 14 { typedef std::array C; Index: libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp =================================================================== --- libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp +++ libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp @@ -49,6 +49,7 @@ test(); } +#if TEST_STD_VER >= 11 struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType1 { }; @@ -56,6 +57,7 @@ struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 { char data[1000]; }; +#endif //static_assert(sizeof(void*) == 4, ""); @@ -64,9 +66,11 @@ test_type(); test_type(); test_type(); +#if TEST_STD_VER >= 11 test_type(); test_type(); test_type(); +#endif return 0; } Index: libcxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp =================================================================== --- libcxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp +++ libcxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp @@ -49,10 +49,11 @@ "std::is_trivial::value"); static_assert(std::is_standard_layout::value, "std::is_standard_layout::value"); -#else +#elif TEST_STD_VER >= 11 static_assert(std::is_pod::value, "std::is_pod::value"); #endif +#if TEST_STD_VER >= 11 static_assert((std::alignment_of::value >= std::alignment_of::value), "std::alignment_of::value >= " @@ -65,6 +66,7 @@ std::alignment_of::value, "std::alignment_of::value >= " "std::alignment_of::value"); +#endif return 0; } Index: libcxx/test/std/language.support/support.types/max_align_t.pass.cpp =================================================================== --- libcxx/test/std/language.support/support.types/max_align_t.pass.cpp +++ libcxx/test/std/language.support/support.types/max_align_t.pass.cpp @@ -18,6 +18,7 @@ int main(int, char**) { +#if TEST_STD_VER >= 11 #if TEST_STD_VER > 17 // P0767 static_assert(std::is_trivial::value, @@ -40,6 +41,7 @@ std::alignment_of::value, "std::alignment_of::value >= " "std::alignment_of::value"); +#endif return 0; } Index: libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp =================================================================== --- libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp +++ libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp @@ -260,9 +260,11 @@ #endif static_assert(std::is_trivial::value, ""); static_assert(std::is_standard_layout::value, ""); +#if TEST_STD_VER >= 11 static_assert(std::alignment_of::value == TEST_ALIGNOF(std::max_align_t), ""); static_assert(sizeof(T1) == 16, ""); +#endif } { typedef std::aligned_storage<17>::type T1; @@ -271,9 +273,11 @@ #endif static_assert(std::is_trivial::value, ""); static_assert(std::is_standard_layout::value, ""); +#if TEST_STD_VER >= 11 static_assert(std::alignment_of::value == TEST_ALIGNOF(std::max_align_t), ""); static_assert(sizeof(T1) == 16 + TEST_ALIGNOF(std::max_align_t), ""); +#endif } { typedef std::aligned_storage<10>::type T1;