From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A43353858D37; Thu, 2 May 2024 11:55:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A43353858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714650926; bh=Df3fPq82BCKbqTkXryAI7I+uo9i3hlUHvHqBcxBXJxI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=R/9KkCQPqoiN+dzCGwvuyxUr5l8TUtb16PBQMUpFcE4oIkSbeVfpCNOWrZjvW9yd1 LRvnll9zqvs6Lem+Fqu77mkAyLApY5QCTSUI2zVKM/47mZHbc4yKIyVDhe6TFtmEN7 hobrrCTtcwFCrs+Rah90rFDNUVFurVUfvcF4/Kcc= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114865] [13/14/15 Regression] std::atomic::compare_exchange_strong seems to hang under GCC 13 for C++11 Date: Thu, 02 May 2024 11:55:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114865 --- Comment #18 from Jonathan Wakely --- So maybe: diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index aa7374bb252..662cff39df5 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -956,7 +956,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr bool __maybe_has_padding() { -#if ! __has_builtin(__builtin_clear_padding) + // We cannot clear padding in the constructor for C++11, + // so return false here to disable all code for zeroing padding. +#if __cplusplus < 201402L || ! __has_builtin(__builtin_clear_padding) return false; #elif __has_builtin(__has_unique_object_representations) return !__has_unique_object_representations(_Tp) diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/ato= mic index 36ff89a146c..336f27832fc 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -238,6 +238,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr atomic(_Tp __i) noexcept : _M_i(__i) { + // A constexpr constructor must be empty in C++11, + // so we can only clear padding for C++14 and later. #if __cplusplus >=3D 201402L && __has_builtin(__builtin_clear_padding) if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Tp>()) __builtin_clear_padding(std::__addressof(_M_i));=