Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!uvaarpa!mcnc!ecsvax!urjlew From: urjlew@ecsvax.UUCP (Rostyk Lewyckyj) Newsgroups: comp.lang.fortran Subject: Re: DO loops, anyone? Summary: Fix the standard! Message-ID: <6667@ecsvax.UUCP> Date: 15 Mar 89 17:16:53 GMT References: <458@orange19.qtp.ufl.edu> <28506@sgi.SGI.COM> <22754@ames.arc.nasa.gov> Organization: UNC Educational Computing Service Lines: 32 Arguing about whether this code conforms to the standard, and/or how it should be interpreted beggs what I think is the real problem and rational solution. The problem is that the standard allows a code construction that easily leads to misuse and stepping over the legal limits. I.e. the standard permits a DO loop to end with non trivial executable statements (eg k=k+1 rather than continue or enddo) and it allows the closure of multiple DO loops on one statement. The defensive/safety minded programmer can easily avoid the problem by liberal use of CONTINUE statements to remove ambiguities. I think that the rational solution is to amend the standard (put it in 8x or 9x if 8x never makes it) to require DO loops to be terminated one at a time with CONTINUE or ENDDO statements. I realize that this will require modifying old source. However since the cases that need modifying can (I think) be caught by the compiler it is not as bad a change as the 0 trip vs 1 trip through the loop change which occured in most 66 to 77 compiler rewrites. I don't think that issuing a warning is enough. PS. I tried the test program on IBM VS FOortran rel v 2.2 and the current compiler on our CONVEX C220. IBM gave two warning messages one for each GOTO 10 and produced differnent values of K depending on the initial value of J. CONVEX gave no warning messages and also produced different values of K. ----------------------------------------------- Reply-To: Rostyslaw Jarema Lewyckyj urjlew@ecsvax.UUCP , urjlew@tucc.bitnet or urjlew@tucc.tucc.edu (ARPA,SURA,NSF etc. internet) tel. (919)-962-9107