https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118953
Bug ID: 118953 Summary: Miscompile at -O3 Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: yunboni at smail dot nju.edu.cn Target Milestone: --- This code prints 45 at -O3 and 0 at -O0/1/2/s: int printf(const char *, ...); int a, d; long b, c; int e(int f, int g, unsigned long h, long j) { unsigned long i = 0; if (g) switch (f) { case 8: i = b; break; case 6: i = c; } else switch (f) { case 8: i = h; break; case 24: case 32: i = j; } return i; } int main() { int k = a * (409628 - 28); d = e(k - 1048524, 0, k - 1048487, (unsigned long)k - 1048531); printf("%d\n", d); } Compiler Explorer: https://godbolt.org/z/YTWjbWe3s Bisected to https://github.com/gcc-mirror/gcc/commit/602e824eec30a7c6792b8b27d61c40f1c1a2714c