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

            Bug ID: 127965
           Summary: wrong code with __atomic_fetch_or
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kyuwoncho18 at gmail dot com
  Target Milestone: ---

#include <stdio.h>

int main(void) {
  int x = 0x80;
  int v = __atomic_fetch_or(&x, 0x80000000, __ATOMIC_SEQ_CST);
  if ((signed char) v < 0)
    return 0;
  return 1;
}


With -O0 or clang -O3, it returns 0, but with GCC -O{1,2,3}, it returns 1.

godbolt: https://gcc.godbolt.org/z/4P8W1Wdq9

Reply via email to