https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117424
Bug ID: 117424 Summary: Miscompile with different optimization flags Product: gcc Version: 12.1.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: --- When I compiled this case by -O3, it terminated with signal: SIGSEGV. When compiled with -O0/O1/O2, its output is 0: ```c int printf(const char *, ...); int a; unsigned char c; int e(int f) { int d = f * 10; return d; } int g(int f, int *l) { int h = 0; for (int j = 0; j < 10; j++) for (int k = 0; k < f; k++) if (l[k]) h++; return h; } int m(int f) { int b = 0, n = g(f, &b); return n; } int main() { int i = 0; for (; e(c + 77) + c - 836 + i < 2; i++) for (; m(c - 5);) ; printf("%d\n", a); } ``` The version of gcc is 12.1. Details can be found here: https://godbolt.org/z/1Kd4s4K7x. I've checked the code with -Wall and -Wextra, no warning has appeared.