Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!i.cc.purdue.edu!h.cc.purdue.edu!s.cc.purdue.edu!ags
From: ags@s.cc.purdue.edu (Dave Seaman)
Newsgroups: comp.lang.fortran
Subject: Re: Dubious Fortran Construct
Keywords: DO loops; transfer of control
Message-ID: <3672@s.cc.purdue.edu>
Date: 7 Dec 88 18:52:45 GMT
References: <22994@sgi.SGI.COM>
Reply-To: ags@s.cc.purdue.edu (Dave Seaman)
Organization: Purdue University
Lines: 26

In article <22994@sgi.SGI.COM> bron@bronze.SGI.COM (Bron Campbell Nelson) writes:
 [asks whether this is legal]
>
>	subroutine foo(a, b, n)
>	real a(n), b(n,n)
>	do 10 i = 1,n
>	    if (a(i) .eq. 0) goto 10
>	    do 10 j = 1,n
>		b(i,j) = 1/a(i)
>10	continue
>
>	return
>	end

This is illegal according to the ANSI standard.  The range of a DO loop, by
definition, consists of all the executable statements following the DO, up
to and including the loop termination statement.  Therefore the CONTINUE is
part of the range of the inner DO.  (It also happens to be part of the
range of the outer DO, but that's irrelevant).

The GOTO is outside the range of the inner DO, but its destination is
inside the range.  Therefore, it's illegal.

-- 
Dave Seaman	  					
ags@j.cc.purdue.edu