https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117574
Bug ID: 117574 Summary: Miscompile with -O2/3 and -O0/1 Product: gcc Version: 9.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 code with -O2/3, it triggered SIGKILL. With -O0/1, it returned 0: ```c int printf(const char *, ...); int a, c; long b; short d; long e(long f, long h, long i) { for (long g = f; g <= h; g += i) b += g; return b; } int main() { c = 1; for (; c >= 0; c--) ; for (; e(d + 40, d + 76, c + 51) < 4;) ; printf("%X\n", a); } ``` I did tried compiled it with -fwrapv and it worked. But I didn't see overflow in this code. You can check here: https://godbolt.org/z/G1T43nPh5 Please let me know if I’ve made any mistakes here. Thanks! The earliest version of this bug is x86_64 9.1.0. Details can be found here: https://godbolt.org/z/1hqYq1af8