https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115647
Bug ID: 115647 Summary: No warning when a loop is infinite due to type of operand in conditional Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- A user sent in this report, noting that it might not be in scope for the analyzer: SUBJECT: Wanalyzer-infinite-loop: Add warning for counter unable to ever not meet condition in `for` loop COMMENT: In the below `for` statement, the `char` counter `i` has a smaller range than the value of the `int` condition `n` (in this case 500) hence it will overflow and wrap around when incremented beyond its max range value (in this case 127) before reaching that value, resulting in an infinite loop. #include <stdio.h> int main (void) { char i; const int n = 500; for (i = 0; i < n; ++i) printf ("%d\n", i); return 0; } Using -Wall, -pedantic, -Wconversion and -fanalyzer on gcc 14.1 doesn't warn about anything for this infinite loop. Maybe this is something -Wanalyzer-infinite-loop should warn about.