This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug c/64843] miscompilation of atomic_fetch_add on atomic pointer type


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


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