]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: std::atomic should use std::addressof
authorJonathan Wakely <jwakely@redhat.com>
Thu, 4 Dec 2025 21:07:19 +0000 (21:07 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Sat, 6 Dec 2025 00:28:43 +0000 (00:28 +0000)
libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h (__detail::__atomic_eq): Use
std::addressof instead of &.
* include/std/atomic (atomic::wait, atomic::notify_one)
(atomic::notify_all): Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
libstdc++-v3/include/bits/atomic_wait.h
libstdc++-v3/include/std/atomic

index 6d8c0de4af68cea062bb81e4f208311bacf87a44..84b8b4c0374b9d5b47c70aad013e54632df90c63 100644 (file)
@@ -118,7 +118,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __atomic_eq(const _Tp& __a, const _Tp& __b)
       {
        // TODO make this do the correct padding bit ignoring comparison
-       return __builtin_memcmp(&__a, &__b, sizeof(_Tp)) == 0;
+       return __builtin_memcmp(std::addressof(__a), std::addressof(__b),
+                               sizeof(_Tp)) == 0;
       }
 
     // Storage for up to 64 bits of value, should be considered opaque bits.
index ccb77fa6327df8982a6ba94a981684b63e09833f..0a510d8f63670e8e3e4bd8f2b79f3c3a504f08ab 100644 (file)
@@ -406,21 +406,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       void
       wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
       {
-       std::__atomic_wait_address_v(&_M_i, __old,
-                          [__m, this] { return this->load(__m); });
+       std::__atomic_wait_address_v(std::addressof(_M_i), __old,
+                                    [__m, this] { return this->load(__m); });
       }
 
       // TODO add const volatile overload
 
       void
       notify_one() noexcept
-      { std::__atomic_notify_address(&_M_i, false); }
+      { std::__atomic_notify_address(std::addressof(_M_i), false); }
 
       void
       notify_all() noexcept
-      { std::__atomic_notify_address(&_M_i, true); }
+      { std::__atomic_notify_address(std::addressof(_M_i), true); }
 #endif // __cpp_lib_atomic_wait
-
     };
 
   /// Partial specialization for pointer types.