diff --git a/stl/inc/algorithm b/stl/inc/algorithm index 81fef0ff11..ee01e63b13 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -90,7 +90,7 @@ struct _Optimistic_temporary_buffer { // temporary storage with _alloca-like att _Ty* _Data; // points to heap memory iff _Capacity > _Optimistic_count ptrdiff_t _Capacity; - aligned_union_t<0, _Ty> _Stack_space[_Optimistic_count]; + _Aligned_storage_t _Stack_space[_Optimistic_count]; }; #ifdef __cpp_lib_concepts diff --git a/stl/inc/condition_variable b/stl/inc/condition_variable index 20b6635d43..10c0088aa8 100644 --- a/stl/inc/condition_variable +++ b/stl/inc/condition_variable @@ -248,7 +248,7 @@ public: private: shared_ptr _Myptr; - aligned_storage_t<_Cnd_internal_imp_size, _Cnd_internal_imp_alignment> _Cnd_storage; + _Aligned_storage_t<_Cnd_internal_imp_size, _Cnd_internal_imp_alignment> _Cnd_storage; _NODISCARD _Cnd_t _Mycnd() noexcept { // get pointer to _Cnd_internal_imp_t inside _Cnd_storage return reinterpret_cast<_Cnd_t>(&_Cnd_storage); diff --git a/stl/inc/mutex b/stl/inc/mutex index 0d8ac1b781..be82a1fbaa 100644 --- a/stl/inc/mutex +++ b/stl/inc/mutex @@ -76,7 +76,7 @@ private: friend condition_variable; friend condition_variable_any; - aligned_storage_t<_Mtx_internal_imp_size, _Mtx_internal_imp_alignment> _Mtx_storage; + _Aligned_storage_t<_Mtx_internal_imp_size, _Mtx_internal_imp_alignment> _Mtx_storage; _Mtx_t _Mymtx() noexcept { // get pointer to _Mtx_internal_imp_t inside _Mtx_storage return reinterpret_cast<_Mtx_t>(&_Mtx_storage); @@ -698,7 +698,7 @@ public: } private: - aligned_storage_t<_Cnd_internal_imp_size, _Cnd_internal_imp_alignment> _Cnd_storage; + _Aligned_storage_t<_Cnd_internal_imp_size, _Cnd_internal_imp_alignment> _Cnd_storage; _Cnd_t _Mycnd() noexcept { // get pointer to _Cnd_internal_imp_t inside _Cnd_storage return reinterpret_cast<_Cnd_t>(&_Cnd_storage); diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 4c3c71fc39..8ac768676b 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1055,15 +1055,24 @@ struct _Aligned<_Len, _Align, char, false> { using type = typename _Aligned<_Len, _Align, _Next, _Fits>::type; }; +// TRANSITION, ABI: Internal non-deprecated version to avoid ABI changes due to deprecation template -struct aligned_storage { // define type with size _Len and alignment _Align +struct _Aligned_storage { // define type with size _Len and alignment _Align using _Next = char; static constexpr bool _Fits = _Align <= alignof(_Next); using type = typename _Aligned<_Len, _Align, _Next, _Fits>::type; }; template -using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; +using _Aligned_storage_t = typename _Aligned_storage<_Len, _Align>::type; + +template +struct _CXX23_DEPRECATE_ALIGNED_STORAGE aligned_storage { // define type with size _Len and alignment _Align + using type = _Aligned_storage_t<_Len, _Align>; +}; + +template +using aligned_storage_t _CXX23_DEPRECATE_ALIGNED_STORAGE = _Aligned_storage_t<_Len, _Align>; template struct _Maximum; @@ -1080,15 +1089,18 @@ struct _Maximum<_First, _Second, _Rest...> : _Maximum<(_First < _Second ? _Secon }; template -struct aligned_union { // define type with size at least _Len, for storing anything in _Types +struct _CXX23_DEPRECATE_ALIGNED_UNION aligned_union { + // define type with size at least _Len, for storing anything in _Types static constexpr size_t _Max_len = _Maximum<_Len, sizeof(_Types)...>::value; // NOT sizeof...(_Types) static constexpr size_t alignment_value = _Maximum::value; - using type = aligned_storage_t<_Max_len, alignment_value>; + using type = _Aligned_storage_t<_Max_len, alignment_value>; }; +_STL_DISABLE_DEPRECATED_WARNING template -using aligned_union_t = typename aligned_union<_Len, _Types...>::type; +using aligned_union_t _CXX23_DEPRECATE_ALIGNED_UNION = typename aligned_union<_Len, _Types...>::type; +_STL_RESTORE_DEPRECATED_WARNING template > struct _Underlying_type { diff --git a/stl/inc/xnode_handle.h b/stl/inc/xnode_handle.h index 077aa77d7e..e6e7627bbe 100644 --- a/stl/inc/xnode_handle.h +++ b/stl/inc/xnode_handle.h @@ -75,7 +75,8 @@ class _Node_handle : public _Base<_Node_handle<_Node, _Alloc, _Base, _Types...>, using _Nodeptr = typename _Alnode_traits::pointer; _Nodeptr _Ptr{}; - aligned_union_t<0, _Alloc> _Alloc_storage; // Invariant: contains a live _Alloc iff _Ptr != nullptr + _Aligned_storage_t + _Alloc_storage; // Invariant: contains a live _Alloc iff _Ptr != nullptr void _Clear() noexcept { // destroy any contained node and return to the empty state if (_Ptr != nullptr) { diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 3961c40de9..88c06ebb29 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -291,6 +291,7 @@ // P1132R7 out_ptr(), inout_ptr() // P1147R1 Printing volatile Pointers // P1272R4 byteswap() +// P1413R3 Deprecate aligned_storage And aligned_union // P1425R4 Iterator Pair Constructors For stack And queue // P1659R3 ranges::starts_with, ranges::ends_with // P1679R3 contains() For basic_string/basic_string_view @@ -1144,7 +1145,31 @@ #define _CXX20_DEPRECATE_IS_ALWAYS_EQUAL #endif // ^^^ warning disabled ^^^ -// next warning number: STL4034 +#if _HAS_CXX23 && !defined(_SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING) \ + && !defined(_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS) +#define _CXX23_DEPRECATE_ALIGNED_STORAGE \ + [[deprecated("warning STL4034: " \ + "std::aligned_storage and std::aligned_storage_t are deprecated in C++23. " \ + "Prefer alignas(T) std::byte t_buff[sizeof(T)]. " \ + "You can define _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING " \ + "or _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS to acknowledge that you have received this warning.")]] +#else // ^^^ warning enabled / warning disabled vvv +#define _CXX23_DEPRECATE_ALIGNED_STORAGE +#endif // ^^^ warning disabled ^^^ + +#if _HAS_CXX23 && !defined(_SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING) \ + && !defined(_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS) +#define _CXX23_DEPRECATE_ALIGNED_UNION \ + [[deprecated("warning STL4035: " \ + "std::aligned_union and std::aligned_union_t are deprecated in C++23. " \ + "Prefer alignas(Ts...) std::byte t_buff[std::max({sizeof(Ts)...})]. " \ + "You can define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING " \ + "or _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS to acknowledge that you have received this warning.")]] +#else // ^^^ warning enabled / warning disabled vvv +#define _CXX23_DEPRECATE_ALIGNED_UNION +#endif // ^^^ warning disabled ^^^ + +// next warning number: STL4036 // P0619R4 Removing C++17-Deprecated Features #ifndef _HAS_FEATURES_REMOVED_IN_CXX20 diff --git a/stl/src/cond.cpp b/stl/src/cond.cpp index 350bb5c60e..46d82ae113 100644 --- a/stl/src/cond.cpp +++ b/stl/src/cond.cpp @@ -12,9 +12,8 @@ #include "primitives.hpp" struct _Cnd_internal_imp_t { // condition variable implementation for ConcRT - std::aligned_storage_t - cv; + typename std::_Aligned_storage::type cv; [[nodiscard]] Concurrency::details::stl_condition_variable_interface* _get_cv() noexcept { // get pointer to implementation diff --git a/stl/src/mutex.cpp b/stl/src/mutex.cpp index 5db8385bec..fcf0efcd19 100644 --- a/stl/src/mutex.cpp +++ b/stl/src/mutex.cpp @@ -40,9 +40,8 @@ extern "C" _CRTIMP2 void __cdecl __set_stl_sync_api_mode(__stl_sync_api_modes_en struct _Mtx_internal_imp_t { // ConcRT mutex int type; - std::aligned_storage_t - cs; + typename std::_Aligned_storage::type cs; long thread_id; int count; Concurrency::details::stl_critical_section_interface* _get_cs() { // get pointer to implementation diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 8ccf16fbfe..60a5168d86 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -221,11 +221,11 @@ std/containers/unord/unord.set/max_size.pass.cpp FAIL std/utilities/tuple/tuple.tuple/tuple.apply/apply_large_arity.pass.cpp SKIPPED std/utilities/tuple/tuple.tuple/tuple.cnstr/recursion_depth.pass.cpp SKIPPED -# Deprecation is a mess. We disable all deprecations in msvc_stdlib_force_include.h to allow libc++ tests for -# deprecated features to pass, which breaks when libc++ deprecates the feature and adds two tests that (1) pass -# with deprecation suppressed, and (2) fail without deprecation suppression. We should instead translate libc++ -# un-deprecation macros to STL un-deprecation macros in the force-include header, and just skip tests when we -# deprecate before they do. +# Deprecation is a mess. We disable all deprecations in llvm-project/libcxx/test/support/msvc_stdlib_force_include.h +# (external to this repo) to allow libc++ tests for deprecated features to pass, which breaks when libc++ deprecates +# the feature and adds two tests that (1) pass with deprecation suppressed, and (2) fail without deprecation suppression. +# We should instead translate libc++ un-deprecation macros to STL un-deprecation macros in the force-include header, +# and just skip tests when we deprecate before they do. std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.deprecated.fail.cpp FAIL diff --git a/tests/libcxx/skipped_tests.txt b/tests/libcxx/skipped_tests.txt index 5c931e01bc..5b05324abc 100644 --- a/tests/libcxx/skipped_tests.txt +++ b/tests/libcxx/skipped_tests.txt @@ -221,11 +221,11 @@ containers\unord\unord.set\max_size.pass.cpp utilities\tuple\tuple.tuple\tuple.apply\apply_large_arity.pass.cpp utilities\tuple\tuple.tuple\tuple.cnstr\recursion_depth.pass.cpp -# Deprecation is a mess. We disable all deprecations in msvc_stdlib_force_include.h to allow libc++ tests for -# deprecated features to pass, which breaks when libc++ deprecates the feature and adds two tests that (1) pass -# with deprecation suppressed, and (2) fail without deprecation suppression. We should instead translate libc++ -# un-deprecation macros to STL un-deprecation macros in the force-include header, and just skip tests when we -# deprecate before they do. +# Deprecation is a mess. We disable all deprecations in llvm-project/libcxx/test/support/msvc_stdlib_force_include.h +# (external to this repo) to allow libc++ tests for deprecated features to pass, which breaks when libc++ deprecates +# the feature and adds two tests that (1) pass with deprecation suppressed, and (2) fail without deprecation suppression. +# We should instead translate libc++ un-deprecation macros to STL un-deprecation macros in the force-include header, +# and just skip tests when we deprecate before they do. utilities\meta\meta.unary\meta.unary.prop\is_literal_type.deprecated.fail.cpp diff --git a/tests/libcxx/usual_matrix.lst b/tests/libcxx/usual_matrix.lst index 3c6d3fe786..193320fdd4 100644 --- a/tests/libcxx/usual_matrix.lst +++ b/tests/libcxx/usual_matrix.lst @@ -3,7 +3,8 @@ RUNALL_INCLUDE ..\universal_prefix.lst RUNALL_CROSSLIST -PM_CL="/EHsc /MTd /std:c++latest /permissive- /FImsvc_stdlib_force_include.h /wd4643 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER" +# TRANSITION, LLVM-53957: _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS belongs to llvm-project/libcxx/test/support/msvc_stdlib_force_include.h +PM_CL="/EHsc /MTd /std:c++latest /permissive- /FImsvc_stdlib_force_include.h /wd4643 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER /D_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS" RUNALL_CROSSLIST PM_CL="/analyze:autolog- /Zc:preprocessor" PM_COMPILER="clang-cl" PM_CL="-fno-ms-compatibility -fno-delayed-template-parsing" diff --git a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp index b4765400c7..35346dc1b6 100644 --- a/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp +++ b/tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include diff --git a/tests/std/tests/Dev11_0000000_user_defined_literals/test.cpp b/tests/std/tests/Dev11_0000000_user_defined_literals/test.cpp index 35a271def5..545da00ef0 100644 --- a/tests/std/tests/Dev11_0000000_user_defined_literals/test.cpp +++ b/tests/std/tests/Dev11_0000000_user_defined_literals/test.cpp @@ -3,6 +3,7 @@ #define _HAS_DEPRECATED_RAW_STORAGE_ITERATOR 1 #define _SILENCE_CXX17_RAW_STORAGE_ITERATOR_DEPRECATION_WARNING +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING #define _SILENCE_EXPERIMENTAL_ERASE_DEPRECATION_WARNING #include diff --git a/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp b/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp index 6a33ce1099..268721302d 100644 --- a/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp +++ b/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING + #include #include #include diff --git a/tests/std/tests/P0035R4_over_aligned_allocation/test.cpp b/tests/std/tests/P0035R4_over_aligned_allocation/test.cpp index 5af1ff3335..7a21362fb2 100644 --- a/tests/std/tests/P0035R4_over_aligned_allocation/test.cpp +++ b/tests/std/tests/P0035R4_over_aligned_allocation/test.cpp @@ -4,6 +4,7 @@ #define _ENABLE_EXTENDED_ALIGNED_STORAGE #define _HAS_DEPRECATED_TEMPORARY_BUFFER 1 #define _SILENCE_CXX17_TEMPORARY_BUFFER_DEPRECATION_WARNING +#define _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING #include #include diff --git a/tests/std/tests/P0088R3_variant/test.cpp b/tests/std/tests/P0088R3_variant/test.cpp index 461e719ec2..836a6edb92 100644 --- a/tests/std/tests/P0088R3_variant/test.cpp +++ b/tests/std/tests/P0088R3_variant/test.cpp @@ -38,6 +38,7 @@ #define _HAS_DEPRECATED_RESULT_OF 1 #define _SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING #define _SILENCE_CXX20_VOLATILE_DEPRECATION_WARNING +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING #define _LIBCXX_IN_DEVCRT #include // Must precede any other libc++ headers diff --git a/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp b/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp index 0f48053e20..48d56c52ea 100644 --- a/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp +++ b/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #define _SILENCE_CXX17_POLYMORPHIC_ALLOCATOR_DESTROY_DEPRECATION_WARNING +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING #include #include diff --git a/tests/std/tests/VSO_0000000_instantiate_type_traits/test.compile.pass.cpp b/tests/std/tests/VSO_0000000_instantiate_type_traits/test.compile.pass.cpp index 6006b36a37..d5a54462d1 100644 --- a/tests/std/tests/VSO_0000000_instantiate_type_traits/test.compile.pass.cpp +++ b/tests/std/tests/VSO_0000000_instantiate_type_traits/test.compile.pass.cpp @@ -6,6 +6,7 @@ #define _SILENCE_CXX17_IS_LITERAL_TYPE_DEPRECATION_WARNING #define _SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING #define _SILENCE_CXX20_IS_POD_DEPRECATION_WARNING +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING #define _USE_NAMED_IDL_NAMESPACE 1 #include diff --git a/tests/tr1/tests/type_traits1/test.cpp b/tests/tr1/tests/type_traits1/test.cpp index 0f2e378fa0..d07015289b 100644 --- a/tests/tr1/tests/type_traits1/test.cpp +++ b/tests/tr1/tests/type_traits1/test.cpp @@ -4,6 +4,9 @@ // test header, part 1 #define TEST_NAME ", part 1" +#define _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING + #include "tdefs.h" #include "typetr.h" #include diff --git a/tests/tr1/tests/type_traits5/test.cpp b/tests/tr1/tests/type_traits5/test.cpp index 87c05096a2..9cdf000555 100644 --- a/tests/tr1/tests/type_traits5/test.cpp +++ b/tests/tr1/tests/type_traits5/test.cpp @@ -5,6 +5,9 @@ #define TEST_NAME ", part 5" #define _DISABLE_EXTENDED_ALIGNED_STORAGE 1 +#define _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING +#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING + #include "tdefs.h" #include "typetr.h" #include