https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112305
Bug ID: 112305 Summary: [13/14 Regression] Wrong code at -O1/2/3/s 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: --- I compiled the following code with gcc at -O1/2/3/s, and it produces the wrong code. The correct output result should be -1560359471, but -486617677 was output under -O1/2/3/s. I found this bug was introduced starting from gcc-13.1 Compiler explorer: https://godbolt.org/z/s7K9z5166 ```c $ cat test.c int printf(const char *, ...); int a; void b() { long c = 3; unsigned int d = 50253292; int e = 2147483648; for (; a < 5; a++) do { e += 4; d -= c; } while (e < 20); printf("%d\n", d); } int main() { b(); } $ $ gcc-tk test.c -O0; ./test.c -1560359471 $ gcc-tk test.c -O1; ./test.c -486617677 $ gcc-tk test.c -O2; ./test.c -486617677 $ gcc-tk test.c -O3; ./test.c -486617677 $ gcc-tk test.c -Os; ./test.c -486617677 $ ccomp test.c -O1; ./a.out -1560359471 $ $ gcc-tk --version gcc (GCC) 14.0.0 20231028 (experimental) [master r14-4987-g7f974c5fd4] Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ $ ccomp --version The CompCert C verified compiler, version 3.12 ```