#does clang have a warning for infinite for loops?
16 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
how do you expect clang would warn you about that? does clang know that the body of the loop won't modify grid->rows in any way? do you expect it to analyze your code to ensure all loops eventually terminate?
do you expect it to analyze your code to ensure all loops eventually terminate?
Ah yes, the halting problem. How can clang not solve such a simple problem?
infinite loops can be intentional
the halting problem proves that there are some programs that cannot be proven to not terminate, not that there are no programs that can be proven to not terminate
Yes, but you have to assume that clang has to also compile such programs where termination can't be proven, therefore you can never rely on it throwing a warning
do people actually rely on the compiler throwing a warning?
They shouldn't, but I bet at least a few people do
I usually use a while loop for infinite loops. maybe a warning if the condition is not the result of comparison and logical operators.
warnings are nice i do not expect myself to have an answer 100% of the time and seeing a warning would be faster than breaking out a debugger. Also the inner logic of the loop could have been wrong like if it were a flood fill algorithm.
Your authoritative answers are annoying without providing any explanation as to why you think you are right.
and i know infinite loops exist just in the context of a for it doesnt not make much sense.
no but if it were to warn if the condition is not the result of comparison operator and logical operators that would be nice. at least in the context of a for loop.
.close
!close