This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/64843] miscompilation of atomic_fetch_add on atomic pointer type
- From: "richard-gccbugzilla at metafoo dot co.uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 28 Jan 2015 21:44:25 +0000
- Subject: [Bug c/64843] miscompilation of atomic_fetch_add on atomic pointer type
- Auto-submitted: auto-generated
- References: <bug-64843-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64843
--- Comment #2 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> ---
libstdc++ uses these builtins in bits/atomic_base.h:
__pointer_type
fetch_add(ptrdiff_t __d,
memory_order __m = memory_order_seq_cst) noexcept
{ return __atomic_fetch_add(&_M_p, _M_type_size(__d), __m); }
Naturally, it's up to you guys how you handle this, but it would be problematic
at least for Clang if the semantics of __atomic_fetch_add change to match the
documentation: we'd somehow need to detect which flavor of libstdc++ is in use
when compiling <atomic>. There may also be user code that depends on the
current semantics that would be broken by changing the de facto semantics (that
have been present for many GCC releases).
Here's Clang's documentation for its __c11_* builtin set:
http://clang.llvm.org/docs/LanguageExtensions.html#c11-atomic-builtins