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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Slightly simpler version of the "fix it by defining OLD_CODE" change, with a
little more context:

--- a/libstdc++-v3/include/ext/atomicity.h
+++ b/libstdc++-v3/include/ext/atomicity.h
@@ -92,24 +92,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

   inline _Atomic_word
   __attribute__((__always_inline__))
   __exchange_and_add_single(_Atomic_word* __mem, int __val)
   {
     _Atomic_word __result = *__mem;
+#ifdef OLD_CODE
+    *__mem += __val;
+#else
+    _Atomic_word __result = *__mem;
     // Do the addition with an unsigned type so that overflow is well defined.
 #if __cplusplus >= 201103L
     std::make_unsigned<_Atomic_word>::type __u;
 #else
     // For most targets make_unsigned_t<_Atomic_word> is unsigned int,
     // but 64-bit sparc uses long for _Atomic_word.
     // Sign-extending to unsigned long works for both cases.
     unsigned long __u;
 #endif
     __u = __result;
     __u += __val;
     *__mem = __u;
+#endif
     return __result;
   }

   inline void
   __attribute__((__always_inline__))
   __atomic_add_single(_Atomic_word* __mem, int __val)

Reply via email to