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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to saugustine from comment #0)
> My uneducated guess is that the template at <atomic>:189 should either use
> &_M_i in calls to __atomic_is_lock_free (instead of nullptr) or should add
> alignment as necessary. Not sure how that is intended to be done. If I fix
> <atomic> to pass the pointer, then gcc chooses to call out to an atomic
> library function, which gcc doesn't provide.

GCC does provide it, in libatomic, so -latomic should work.

But I just tried your suggested change and saw no effect: I didn't need
libatomic and I still got a bus error.

I suppose what we want is the equivalent of this, but the _Atomic keyword isn't
valid in C++:

--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -161,7 +161,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct atomic
     {
     private:
-      _Tp _M_i;
+      alignas(alignof(_Atomic _Tp)) _Tp _M_i;

       // TODO: static_assert(is_trivially_copyable<_Tp>::value, "");

Reply via email to