[…] Is there a way to enable a warning/error/hint so it warns us of this? […]
You may be interested in following issues
#12508 and
#34248.
[…] The control variable ends up with no defined (i.e. predictable) value. It does not in some way become undeclared, or have a special value assigned to it that code can subsequently recognise as an undefined value. […]
Well, then it is merely a matter of
always resetting the “
not initialized flag” so a warning is emitted. Although I find it quite useless then, you know, if the control variable’s preceding
initialized state is revoked no matter what, then it’s like “warning: program
may run
successfully”.
[…] While I agree that 11 would have been an more expected result than 10 […]
This
may be because you were
familiarized with C (or a similar programming language)
first, or maybe you are
not capable of abstracting from the low‑level implementation details and the semantics of high‑level programming language. For me as a “Pascal native” a value of
11 is
unintuitive.
[…]For i:=1 To 10 Do
Begin
If i=10 Then Break;
End;
//What's the definite state of i?
[…]
It is defined to be
10.
EDIT: An additional issue has been mentioned and linked.