https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115647
--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> --- There's no warning from the analyzer below -O1: https://godbolt.org/z/34js3xT8G but there is at -O1 and above: https://godbolt.org/z/5z9x1vP6G which reports: <source>: In function 'main': <source>:10:5: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop] 10 | printf ("%d\n", i); | ^~~~~~~~~~~~~~~~~~ 'main': event 1 10 | printf ("%d\n", i); | ^~~~~~~~~~~~~~~~~~ | | | (1) ⚠️ infinite loop here 'main': event 2 cc1: (2): looping back... 'main': event 3 10 | printf ("%d\n", i); | ^~~~~~~~~~~~~~~~~~ | | |└───>(3) ...to here This was surprising to me, as -Wanalyzer is meant to not report on infinite loops with side-effects, and printf ought to be a side-effect. That said, we probably ought to warn for the conditional 'i < n' given that it will always be true given the value of n and the type of i. Such a warning might be better implemented in the frontends; not sure.