https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114386
Bug ID: 114386 Summary: [10/11/12 Regression] Miscompile at -O1 Product: gcc Version: 12.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: patrick at rivosinc dot com Target Milestone: --- Testcase: int printf(const char *, ...); _Bool a, c = 1; int b, d; int main() { _Bool g = c; d = !a ? ({ c > a ? c : a; }) : 0; printf("%x\n", d); } Commands: > gcc -O0 red.c -o red.o > ./red.o 0 > gcc -O1 red.c -o red.o > ./red.o 1 > gcc -O2 red.c -o red.o > ./red.o 0 > gcc -O3 red.c -o red.o > ./red.o 1 Tested/discovered on x86 - gcc v11.4.0. Issue is not present when targeting risc-v. Godbolt shows it's a regression starting at 10.1 (with -O1) and resolved as of 13.1. Godbolt: https://godbolt.org/z/q4P9xs5dx