public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/114865] [13/14/15 Regression] std::atomic<X>::compare_exchange_strong seems to hang under GCC 13  for C++11
Date: Thu, 02 May 2024 11:55:26 +0000	[thread overview]
Message-ID: <bug-114865-4-QT0XFvv9nI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114865-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114865

--- Comment #18 from Jonathan Wakely <redi at gcc dot gnu.org> ---
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/atomic
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 >= 201402L && __has_builtin(__builtin_clear_padding)
        if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Tp>())
          __builtin_clear_padding(std::__addressof(_M_i));

  parent reply	other threads:[~2024-05-02 11:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 15:50 [Bug libstdc++/114865] New: std::atomic<X>::compare_exchange_strong seems to hang under GCC 13 on Ubuntu 23.04 pdimov at gmail dot com
2024-04-26 17:47 ` [Bug libstdc++/114865] " pdimov at gmail dot com
2024-04-26 19:40 ` pdimov at gmail dot com
2024-04-26 23:14 ` [Bug libstdc++/114865] [13/14/15 Regression] " pinskia at gcc dot gnu.org
2024-04-26 23:16 ` pinskia at gcc dot gnu.org
2024-04-27  0:13 ` pdimov at gmail dot com
2024-04-27  0:16 ` pinskia at gcc dot gnu.org
2024-04-27  0:16 ` pinskia at gcc dot gnu.org
2024-04-27  0:22 ` pinskia at gcc dot gnu.org
2024-04-27  0:25 ` pinskia at gcc dot gnu.org
2024-04-27  0:29 ` pdimov at gmail dot com
2024-04-27  0:31 ` pdimov at gmail dot com
2024-04-27  0:35 ` [Bug libstdc++/114865] [13/14/15 Regression] std::atomic<X>::compare_exchange_strong seems to hang under GCC 13 for C++11 pinskia at gcc dot gnu.org
2024-04-27  0:38 ` pdimov at gmail dot com
2024-04-27  0:42 ` pinskia at gcc dot gnu.org
2024-04-27  0:42 ` pdimov at gmail dot com
2024-05-02 11:40 ` redi at gcc dot gnu.org
2024-05-02 11:41 ` redi at gcc dot gnu.org
2024-05-02 11:44 ` redi at gcc dot gnu.org
2024-05-02 11:47 ` redi at gcc dot gnu.org
2024-05-02 11:55 ` redi at gcc dot gnu.org [this message]
2024-05-02 15:13 ` pdimov at gmail dot com
2024-05-21  9:20 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114865-4-QT0XFvv9nI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).