From 92d1e1f4d9b2c0c52b145adb598f0e27ff0203d2 Mon Sep 17 00:00:00 2001 From: Adam Bucior <35536269+AdamBucior@users.noreply.github.com> Date: Mon, 16 Dec 2019 17:05:42 +0100 Subject: [PATCH 1/4] Implement P0883R2 --- stl/inc/atomic | 14 ++++---------- stl/inc/yvals_core.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/stl/inc/atomic b/stl/inc/atomic index ec2bc75277b..1ea982628e6 100644 --- a/stl/inc/atomic +++ b/stl/inc/atomic @@ -1443,11 +1443,7 @@ public: using _Base::_Base; -#ifdef __clang__ // TRANSITION, VSO-406237 constexpr atomic() noexcept(is_nothrow_default_constructible_v<_Ty>) : _Base() {} -#else // ^^^ no workaround / workaround vvv - atomic() = default; -#endif // TRANSITION, VSO-406237 atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; @@ -1609,7 +1605,8 @@ _NODISCARD bool atomic_is_lock_free(const atomic<_Ty>* _Mem) noexcept { } template -void atomic_init(atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept { +_CXX20_DEPRECATE_ATOMIC_INIT void atomic_init( + atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept { #if 1 // TRANSITION, ABI _CSTD memcpy(_STD addressof(_Mem->_Storage), _STD addressof(_Value), sizeof(_Ty)); #else // ^^^ don't break ABI / break ABI vvv @@ -1619,7 +1616,8 @@ void atomic_init(atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type } template -void atomic_init(volatile atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept { +_CXX20_DEPRECATE_ATOMIC_INIT void atomic_init( + volatile atomic<_Ty>* const _Mem, const typename atomic<_Ty>::value_type _Value) noexcept { // NB: respecting volatility here appears unimplementable _STD atomic_init(const_cast*>(_Mem), _Value); } @@ -1947,11 +1945,7 @@ struct atomic_flag { // flag with test-and-set semantics _Storage.store(false, _Order); } -#ifdef __clang__ // TRANSITION, VSO-406237 constexpr atomic_flag() noexcept = default; -#else // ^^^ no workaround / workaround vvv - atomic_flag() noexcept = default; -#endif // TRANSITION, VSO-406237 #if 1 // TRANSITION, ABI atomic _Storage; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index aafec2118e6..a13ad093a10 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -54,6 +54,7 @@ // P0771R1 noexcept For std::function's Move Constructor // P0777R1 Avoiding Unnecessary decay // P0809R0 Comparing Unordered Containers +// P0883R2 Fixing Atomic Initialization // P0941R2 Feature-Test Macros // P0972R0 noexcept For zero(), min(), max() // P1164R1 Making create_directory() Intuitive @@ -853,6 +854,18 @@ #define _DEPRECATE_EXPERIMENTAL_ERASE #endif // ^^^ warning disabled ^^^ +#if _HAS_CXX20 && !defined(_SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING) \ + && !defined(_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS) +#define _CXX20_DEPRECATE_ATOMIC_INIT \ + [[deprecated("warning STL4026: " \ + "std::atomic_init() overloads are deprecated in C++20. " \ + "The constructors of std::atomic provide equivalent functionality. " \ + "You can define _SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING " \ + "or _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS to acknowledge that you have received this warning.")]] +#else // ^^^ warning enabled / warning disabled vvv +#define _CXX20_DEPRECATE_ATOMIC_INIT +#endif // ^^^ warning disabled ^^^ + // next warning number: STL4027 @@ -946,6 +959,8 @@ #endif // _HAS_CXX17 // C++20 +#define __cpp_lib_atomic_value_initialization 201911L + #if _HAS_CXX20 #define __cpp_lib_atomic_float 201711L #define __cpp_lib_bind_front 201907L From 6bb0e5d2d352693e2fb63145462d34417fb7ad7c Mon Sep 17 00:00:00 2001 From: Adam Bucior <35536269+AdamBucior@users.noreply.github.com> Date: Mon, 16 Dec 2019 17:32:32 +0100 Subject: [PATCH 2/4] Make clang-format happy --- stl/inc/yvals_core.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index a13ad093a10..17fcf6c5c58 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -856,11 +856,11 @@ #if _HAS_CXX20 && !defined(_SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING) \ && !defined(_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS) -#define _CXX20_DEPRECATE_ATOMIC_INIT \ - [[deprecated("warning STL4026: " \ - "std::atomic_init() overloads are deprecated in C++20. " \ - "The constructors of std::atomic provide equivalent functionality. " \ - "You can define _SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING " \ +#define _CXX20_DEPRECATE_ATOMIC_INIT \ + [[deprecated("warning STL4026: " \ + "std::atomic_init() overloads are deprecated in C++20. " \ + "The constructors of std::atomic provide equivalent functionality. " \ + "You can define _SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING " \ "or _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS to acknowledge that you have received this warning.")]] #else // ^^^ warning enabled / warning disabled vvv #define _CXX20_DEPRECATE_ATOMIC_INIT From c8951a3c1f6dc0b024935d69e2c3abfbaf9de453 Mon Sep 17 00:00:00 2001 From: Adam Bucior <35536269+AdamBucior@users.noreply.github.com> Date: Mon, 16 Dec 2019 20:18:05 +0100 Subject: [PATCH 3/4] Update warning number Co-Authored-By: Casey Carter --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 17fcf6c5c58..2ffecf1ec02 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -857,7 +857,7 @@ #if _HAS_CXX20 && !defined(_SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING) \ && !defined(_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS) #define _CXX20_DEPRECATE_ATOMIC_INIT \ - [[deprecated("warning STL4026: " \ + [[deprecated("warning STL4027: " \ "std::atomic_init() overloads are deprecated in C++20. " \ "The constructors of std::atomic provide equivalent functionality. " \ "You can define _SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING " \ From 39a7577cf947306bfa58049220e683e0fd8f6e2e Mon Sep 17 00:00:00 2001 From: Adam Bucior <35536269+AdamBucior@users.noreply.github.com> Date: Mon, 16 Dec 2019 20:19:55 +0100 Subject: [PATCH 4/4] Update next warning number --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 2ffecf1ec02..bf7ac8d7171 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -866,7 +866,7 @@ #define _CXX20_DEPRECATE_ATOMIC_INIT #endif // ^^^ warning disabled ^^^ -// next warning number: STL4027 +// next warning number: STL4028 // LIBRARY FEATURE-TEST MACROS