https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64843
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Known to fail| |4.9.3, 6.0 --- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> --- See also bug 52291. This never worked correctly and the bug still exists on trunk (6.0). The C11 operations are expected to work on "address types" (which is a term inadvertently held over from the original proposal). There are other problems with the C11 specification and WG14 has started to clean this up. The DR that comes closest to addressing this is DR 486, though I expect it to be superseded by future, more focused papers. $ cat a.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -Wall -Wextra a.c && ./a.out #include <stdatomic.h> int main (void) { int a[2] = { 1, 2 }; { int *p = a; int *q = __sync_fetch_and_add (&p, 2); __builtin_printf ("%p => %p\n", a, p); } { int *p = a; int *q = __atomic_fetch_add (&p, 2, 0); __builtin_printf ("%p => %p\n", a, p); } { int* _Atomic p = a; int *q = atomic_fetch_add (&p, 2); __builtin_printf ("%p => %p\n", a, p); if (p != a + 2) __builtin_abort (); } } a.c: In function ‘main’: a.c:9:14: warning: unused variable ‘q’ [-Wunused-variable] int *q = __sync_fetch_and_add (&p, 2); ^ a.c:16:14: warning: unused variable ‘q’ [-Wunused-variable] int *q = __atomic_fetch_add (&p, 2, 0); ^ a.c:24:14: warning: unused variable ‘q’ [-Wunused-variable] int *q = atomic_fetch_add (&p, 2); ^ 0x3fffc5851208 => 0x3fffc585120a 0x3fffc5851208 => 0x3fffc585120a 0x3fffc5851208 => 0x3fffc585120a Aborted