[Bug middle-end/87237] __atomic_load on 4-byte-sized, 1-byte-aligned struct is not atomic

amonakov at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Sep 11 18:50:00 GMT 2018


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

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amonakov at gcc dot gnu.org

--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
GCC assumes the access is sufficiently aligned for an atomic object of
corresponding type, so either the documentation needs to mention that, or gcc
should stop "upgrading" alignment.

typedef int i1 __attribute__((aligned(1)));

int f(i1 *p)
{
  return __atomic_load_n(p, __ATOMIC_RELAXED);
}


We expand the load to (note A32)

(insn 6 3 7 2 (set (reg:SI 87 [ _4 ])
        (mem/v:SI (reg/v/f:DI 89 [ p ]) [-1  S4 A32])) ttt.c:5 -1
     (nil))


More information about the Gcc-bugs mailing list