https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89134
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- Right, the problem is that do_something() could do one of the things that the standard says permit loops to iterate infinitely: An iteration statement whose controlling expression is not a constant expression, that performs no input/output operations, does not access volatile objects, and performs no synchronization or atomic operations in its body, controlling expression, or (in the case of for statement) its expression-3, may be assumed by the implementation to terminate. If do_something() were declared pure like inc() it couldn't do any of those things either and GCC should be able to assume the loop terminates. It doesn't, and in fact, it doesn't even in its absence. For example, GCC doesn't think the following loop necessarily terminates either: void test (int n) { for (int i = 0; i < n; i = inc (i)); } Not even when inc() is declared const.