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

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
While working on this, I've found something weird, as shown in the following
testcase:

int
main (void)
{
  _Atomic _Bool a = 1;
  __builtin_printf ("%d\n", a);
  __atomic_fetch_add (&a, 1, __ATOMIC_SEQ_CST);
  __builtin_printf ("%d\n", a);

  _Atomic _Bool b = 1;
  __builtin_printf ("%d\n", b);
  ++b;
  __builtin_printf ("%d\n", b);

  if (a != b)
    __builtin_abort ();
}
crashes, i.e. given _Atomic _Bool x = 1;
++x == 1, but
__atomic_fetch_add (&x, 1, __ATOMIC_SEQ_CST) == 2.

And because of that my patch to implement this optimization regresses
c11-atomic-exec-2.c and c11-atomic-exec-3.c, where we deal with incrementing
atomic bool.

Reply via email to