At the beginning there’s a sad story: many years ago, the C++ compiler started giving warnings for while(true) C4127: conditional expression is constant...
Because I used while(true) everywhere and our policy was ‘no warnings allowed,’ I spent a lot of time fixing them..
Just to be sure I won’t have to do all this again.
There are many things that you can level at NASA, this is not one of them. The rules are almost certainly backed up by statistical analysis. In addition, there is a broader context. Quoting:
Rationale: The absence of recursion and the presence of loop bounds prevents
runaway code. This rule does not, of course, apply to iterations that are meant to be
non-terminating (e.g., in a process scheduler). In those special cases, the reverse rule
is applied: it should be statically provable that the iteration cannot terminate.
One way to support the rule is to add an explicit upper-bound to all loops that have a
variable number of iterations (e.g., code that traverses a linked list).
In addition, the necessity to use while(true) generally also requires me to deal with an extra variable in an outer scope which may collide and cause an error, in the case of Zig. None of which would be necessary with do/while which limits the scope of the loop variable.