LGTM

On Fri, 5 Dec 2025, Jonathan Wakely wrote:

> 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.
> ---
> 
> Tested x86_64-linux.
> 
>  libstdc++-v3/include/bits/atomic_wait.h | 3 ++-
>  libstdc++-v3/include/std/atomic         | 9 ++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libstdc++-v3/include/bits/atomic_wait.h 
> b/libstdc++-v3/include/bits/atomic_wait.h
> index 6d8c0de4af68..84b8b4c0374b 100644
> --- a/libstdc++-v3/include/bits/atomic_wait.h
> +++ b/libstdc++-v3/include/bits/atomic_wait.h
> @@ -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.
> diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
> index ccb77fa6327d..0a510d8f6367 100644
> --- a/libstdc++-v3/include/std/atomic
> +++ b/libstdc++-v3/include/std/atomic
> @@ -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.
> -- 
> 2.52.0
> 
> 

Reply via email to