I had just taken the decision to change as many variables from unsigned
to int
and upon recompiling the code in question, was greeted by this warning message:
freespace_state.c:203: warning: assuming that the loop is not infinite
The line in question:
for (x = startx; x <= endx; ++x, ++xptr)
This loop is 60 lines of code (inc white space/brackets etc), and has a goto
within it, and at least one occurrence of continue
.
In this case, I think I am appreciative that GCC is assuming this loop is not infinite, because, it should never loop indefinitely.
What is GCC trying to tell me here?
The grammar of the warning is almost suggestive that the warning should be taken within the context of some other warning, but there are none within that context.
[edit] It's all completely my own fault. I stole some optimization and warning options from a question on here somewhere without really understanding them, and had since forgotten about them.
See Mark Rushakoff's answer, and in addition, I have also used -Wunsafe-loop-optimizations
to explicitly warn if GCC is making assumptions about a loop. See http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html