J. David Bryan wrote:
Nearly. ;-) I believe item "g" actually refers to this case:
for i := 1 to 10 do for i := 11 to 20 do ;
The second for-statement is contained in the first and threatens the first for-statement's control variable, and so is illegal by item "g".
Alright, this makes sense.
Yes, but is a goto into a loop legal at all (the last sentence of 6.9.2.4 seems to indicate not to me, but I'm not completely sure)?
[...]
(c) S is a statement of the statement-sequence of the compound-statement of the statement-part of a block containing G."
Wow, 4 "of"s in a row! ;-)
Item "b" appears to be the key, as the question fails items "a" and "c". Going out of a for-statement is legal:
for i := 1 to 10 do goto 1; 1: ;
...because the for-statement (part of the statement-sequence containing G) and the null-statement (S) are both part of the same statement-sequence. However, going into a for-statement is not legal:
goto 1; for i := 1 to 10 do 1: ;
...because the null-statement (S) is not part of the statement-sequence containing the goto-statement (the statement-sequence containing the goto- statement consists of the goto-statement and the for-statement but *not* the null-statement).
It took me three days of head-scratching to decide this, so I hope I am correct (this time)!
I hope so, too -- it does make sense, after all...
Frank