Path: utzoo!attcan!uunet!lll-winken!ames!hc!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: An exercise in futility (was Results of the UGLY code) Message-ID: <7962@lanl.gov> Date: 13 Jan 89 01:50:44 GMT References: <583@mbph.UUCP> Organization: Los Alamos National Laboratory Lines: 34 I haven't read this group for some months so I missed this discussion. But, there is nothing ambiguous about this example in the standard. > >> K = 0 >> DO 10 I = 1,10 >> 1 IF (I.EQ.1.OR.I.EQ.5) GOTO 10 >> DO 10 J = 1,10 >> IF (J.EQ.3) GOTO 10 >> 10 K = K + 1 >> PRINT *,K >> END > According to the standard: 11.10.1 Range of a DO-Loop. The range of a DO-loop consists of all the executable statements that appear following the DO statement that specifies the DO-loop, up to and including the terminal statement of the DO-loop. So, the statement labeled 10 in the above is within the range of the innermost DO-loop. Now, again the standard: 11.10.8 Transfer into the Range of a DO-Loop. Transfer of control into the Range of a DO-loop from outside the range is not permitted. So, the conditional GOTO on the statement labeled 1 is NOT standard conforming since it transfers control to a statement that is inside the range of the inner loop. Confusion on this point only arises because Do-loops are allowed to share terminal statements - probably a bad idea, but we're stuck with it now. J. Giles