Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!rice!uw-beaver!cornell!batcomputer!theory.TC.Cornell.EDU!riley From: riley@theory.TC.Cornell.EDU (Daniel S. Riley) Newsgroups: comp.sys.mips Subject: Re: f77 compiler bug (both MIPS and SGI) Message-ID: <1991Jun19.162129.2870@batcomputer.tn.cornell.edu> Date: 19 Jun 91 16:21:29 GMT References: <1991Jun17.224729.15190@rice.edu> <1991Jun18.191622.4008@odin.corp.sgi.com> <1991Jun19.133207.24629@cpsc.ucalgary.ca> Sender: news@batcomputer.tn.cornell.edu Organization: Cornell Theory Center Lines: 41 Nntp-Posting-Host: theory.tc.cornell.edu In article <1991Jun19.133207.24629@cpsc.ucalgary.ca>, cliff@phys.ucalgary.ca writes: >>>I've discovered an interesting 'glitch' in the f77 compiler for >>>MIPS (and consequently, for SGI, also). given a code skeleton of : >>> >>> if (...) goto 10 >>> . >>> do 10 .... >>> . >>>10 continue > Many thanks to all that pointed out that jumping into a loop is illegal. > But strictly speaking, the above is not illegal. Older f77 compilers > understood that this meant to skip over the code from the 'if' to the > '10 continue'. (example: the 4.3BSD (circa '87) compiler handles this > code just fine and produces the *correct* results. Anyway, it really > just a look into the past (f66) since it is bad coding style! {-8 Just because some compiler accepts it and does what you want does not mean that it is legal code. To quote chapter and verse, from ANSI X3.9-1978 (FORTRAN 77), page 11-6, 11.10.1 Range of a DO-Loop. The range of a DO-Loop consists of all of the executable statements that appear following the DO statement that specifies the DO-Loop, up to and including the terminal statment of the DO-Loop. and page 11-9, 11.10.8 Transfer into the range of a DO-Loop. Transfer into the range of a DO-Loop from outside of the loop is not permitted. Since the terminal statement is part of the range of the DO-Loop, the code above is unambiguously illegal, strictly speaking, according to the ANSI FORTRAN 77 standard. -- -Dan Riley (riley@theory.tc.cornell.edu, cornell!batcomputer!riley) -Wilson Lab, Cornell University