[libcxx-commits] [libcxx] [libc++] Implement P0528R3 `std::atomic` CAS for types with padding (PR #76180)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 28 02:40:18 PDT 2026


================
@@ -126,23 +136,34 @@ _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
     _Tp __value,
     memory_order __success,
     memory_order __failure) _NOEXCEPT {
-  return __c11_atomic_compare_exchange_strong(
-      std::addressof(__a->__a_value),
+  return std::__atomic_cas_with_clear_padding(
       __expected,
       __value,
-      static_cast<__memory_order_underlying_t>(__success),
-      static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
+      // Use always_inline since Clang fails to inline the lambda, even when the memory order is a constant
+      [__a, __success, __failure](_Tp* __expected_or_copy, _Tp __value_maybe_padding_cleared) _LIBCPP_ALWAYS_INLINE {
----------------
huixie90 wrote:

Ah Ok. Let me know if the comment is unclear. The detailed discussion is here https://github.com/llvm/llvm-project/pull/76180#discussion_r3647291757

https://github.com/llvm/llvm-project/pull/76180


More information about the libcxx-commits mailing list