https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111290
Bug ID: 111290 Summary: [11/12/13/14 Regression] Wrong code at -O0 on x86_64-pc-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: jwzeng at nuaa dot edu.cn Target Milestone: --- Compiler Explorer: https://godbolt.org/z/Ee3fMoqPr The following code snippet, gcc at -O0 produces the wrong code. I tested it on other versions of gcc and found that this bug was introduced starting from `gcc-4.9.0`. $ cat test.c #include <stdint.h> int printf(const char *, ...); volatile uint16_t a = (unsigned short)27267; volatile int32_t b = 191725925; volatile int32_t c = 633417204; volatile uint64_t d = 6049561019410052129ULL; volatile int32_t e = 2024295172; volatile int8_t res = (signed char)108; int main() { b = (c |= d / a) >= ((e %= 0x6B1D8456) > (res ^= c)); printf("%d\n", res); } $ $ gcc-tk test.c; ./a.out -104 $ gcc-4.9.0 test.c; ./a.out -104 $ gcc-4.8.5 test.c; ./a.out -112 $ clang-tk test.c; ./a.out -112 $ ccomp test.c; ./a.out -112 $ $ gcc-tk --version gcc (GCC) 14.0.0 20230829 (experimental) [master r14-3534-gebffc840f5] Copyright (C) 2023 Free Software Foundation, Inc. $ $ gcc-4.9.0 --version gcc (GCC) 4.9.0 Copyright (C) 2014 Free Software Foundation, Inc. $ $ gcc-4.8.5 --version gcc (GCC) 4.8.5 Copyright (C) 2015 Free Software Foundation, Inc. $ $ clang-tk --version Ubuntu clang version 18.0.0 (++20230821052626+634b2fd2cac2-1~exp1~20230821172748.738) Target: x86_64-pc-linux-gnu $ $ ccomp --version The CompCert C verified compiler, version 3.12