This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix ODR violations in code using <ext/atomicity.h>

On 05/07/19 19:44 +0100, Jonathan Wakely wrote:
On 05/07/19 20:23 +0200, Daniel Krügler wrote:
Am Fr., 5. Juli 2019 um 18:13 Uhr schrieb Jonathan Wakely <>:

I decided against the simplification in the second patch, and
committed the attached one which is closer to the first patch I sent
(preserving the __atomic_add and __exchange_and_add functions even
when they just call the built-ins).

Tested x86_64-linux, powerpc64-linux, powerpc-aix. Committed to trunk.

Unrelated to the actual patch, I noticed some explicit "throw()" forms
used as exception specifications - shouldn't these be replaced by
either explicit "noexcept" or at least by a library macro that expands
to one or the other?

Yes, they should be _GLIBCXX_NOTHROW.

(I'm sorry, if such unrelated questions are
considered as inappropriate for this list).

Entirely appropriate, thanks!

Here's a patch to fix that and the dumb mistake I made in
__atomic_add_dispatch. I'll commit after testing finishes.

commit 1542776ebab8848109d125d05a548fca5efb513a
Author: Jonathan Wakely <>
Date:   Sat Jul 6 21:24:51 2019 +0100

    Fix recent regression in __atomic_add_dispatch
            * include/ext/atomicity.h (__exchange_and_add, __atomic_add): Replace
            throw() with _GLIBCXX_NOTHROW.
            (__atomic_add_dispatch): Return after performing atomic increment.

diff --git a/libstdc++-v3/include/ext/atomicity.h b/libstdc++-v3/include/ext/atomicity.h
index 73225b3de20..333c8843e14 100644
--- a/libstdc++-v3/include/ext/atomicity.h
+++ b/libstdc++-v3/include/ext/atomicity.h
   { __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
-  __exchange_and_add(volatile _Atomic_word*, int) throw ();
+  __exchange_and_add(volatile _Atomic_word*, int) _GLIBCXX_NOTHROW;
-  __atomic_add(volatile _Atomic_word*, int) throw ();
+  __atomic_add(volatile _Atomic_word*, int) _GLIBCXX_NOTHROW;
   inline _Atomic_word
 #ifdef __GTHREADS
     if (__gthread_active_p())
-      __atomic_add(__mem, __val);
+      {
+	__atomic_add(__mem, __val);
+	return;
+      }
     __atomic_add_single(__mem, __val);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]