https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98250
Bug ID: 98250 Summary: Wrong code path with -O1 and signed overflow Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: stransky.peter at googlemail dot com Target Milestone: --- Wrong code path after signed overflow in gcc-10 and optimization > O1. Problem seems to be introduced somewhere between gcc-6 and gcc-8. #include <stdio.h> void foo(int n) { if (n > 0) { ++n; printf("n=%d\n", n); if(n > 0) { printf("Should not get here.\n"); } } } int main() { foo(0x7fffffff); return 0; } g++ issue.cc -o issue && ./issue n=-2147483648 g++ issue.cc -o issue -O1 && ./issue n=-2147483648 Should not get here.