I know there have been a number of discussions of whether break and continue should be considered harmful generally (with the bottom line being - more or less - that it depends; in some cases they enhance clarity and readability, but in other cases they do not).
Suppose a new project is starting development, with plans for nightly builds including a run through a static analyzer. Should it be part of the coding guidelines for the project to avoid (or strongly discourage) the use of continue
and break
, even if it can sacrifice a little readability and require excessive indentation? I'm most interested in how this applies to C code.
Essentially, can the use of these control operators significantly complicate the static analysis of the code possibly resulting in additional false negatives, that would otherwise register a potential fault if break or continue were not used?
(Of course a complete static analysis proving the correctness of an aribtrary program is an undecidable proposition, so please keep responses about any hands-on experience with this you have, and not on theoretical impossibilities)
Thanks in advance!
break
and without introducing more local variables? If not, then makingbreak
harder to use is going to make writing at least one common code pattern harder.break
andcontinue
are simple to reflect in control flow graphs. In fact, I don't think there would be significant differences between the CFGs of loops usingbreak
/continue
and those usingif
and flags to achieve the same control flow. So any static analysis tool that uses CFGs should treat them the same way - of course, I don't know if any actually do, otherwise I'd post an answer.