https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100702
Bug ID: 100702 Summary: Strict overflow warning regression in gcc 8 onwards Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: david at westcontrol dot com Target Milestone: --- Incorrect code like this example relies on two's complement wrapping to do what the programmer wanted: void foo(int *a) { int i; for (i=0; i<i+1; i++) a[i&256]=0; } Since signed integer overflow is undefined behaviour, gcc optimises code like that to an infinite loop. That's fair enough. But it would always be helpful with a warning about such cases. For gcc 7 and below, gcc can generate a warning but only if "-Wstrict-overflow=5" is used. gcc 8 and above have no warning, even with that flag (and -Wall -Wextra -O2). I realise that these things can change between versions due to re-arrangement of compiler passes and other differences. But is there a possibility of a warning when assumptions about undefined behaviour lead to infinite loops? (The compiler knows the loop is infinite - it doesn't bother generating a return opcode.)