https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118013
David Malcolm <dmalcolm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2024-12-13 Summary|bogus "infinite loop" |bogus "infinite loop" |warning |warning due to -fanalyzer | |not restricting range of | |iterator variable Ever confirmed|0 |1 --- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> --- Thanks for filing this bug report. Confirmed; reproducer on GCC trunk with Compiler Explorer: https://godbolt.org/z/TGh8sbjYc which shows the control flow in a slightly different way (hopefully more readable). It looks like the analyzer is considering the (impossible) path in which we exit the inner loop due to (j >= nsubst) but also fail to execute the increment of "i" due to: j != nsubst i.e. that: j > nsubst which of course isn't possible, since j is being incremented up from 0 until it reaches nsubst, and thus can only be in the range [0, nsubst]. Looks like the analyzer needs to be smarter about iteration variables.