I have a few old programs that do this - it is legal in f77 and actually has a
special name that I cannot recall at the moment. Absoft likes and runs it correctly.
[dir:~/tests/gfortran] dir% f77 -o jump jump.f
FORTRAN 77 Compiler 8.0a, Copyright (c) 1987-2003, Absoft Corp.
[dir:~/tests/gfortran] dir% jump
[dir:~/tests/gfortran] dir% gfortran -o jump jump.f
In file jump.f:4
In file jump.f:9
Error: Label at (1) is not in the same block as the GOTO statement at (2)
[dir:~/tests/gfortran] dir% cat jump.f
do 20 i=1,2
go to 30
Hmm, g77 just warned about it:
t.f: In program `main':
Reference to label at (2) is outside block containing definition at (1)
This is illegal code with respect to F77.
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
I haven't looked in the F2003 standard, but I suspect it is also illegal.
Here's a little more info from the F77 standard, Appendix A.
A2. Conflicts with ANSI X3.9-1966
An extremely important consideration in the preparation of this
standard was the minimization of conflicts with the previous
standard, ANSI X3.9-1966. This standard includes changes that
create conflicts with ANSI X3.9-1966 only when such changes were
necessary to correct an error in the previous standard or to add
to the power of the FORTRAN language in a significant manner.
The following is a list of known conflicts:
(7) This standard does not permit a transfer of control into the
range of a DO-loop from outside the range. The range of a
DO-loop may be entered only by the execution of a DO statement.
ANSI X3.9-1966 permitted transfer of control into the range of
a DO-loop under certain conditions. This involved the concept
referred to as "extended range of a DO."
I think that this can be closed with a WONTFIX, since there is
nothing to fix.
(In reply to comment #3)
> Here's a little more info from the F77 standard, Appendix A.
Hmm, people still have fortran 66 code floating around.
Downgrading this to enhancement. 27 years of this not being allowed are a long time.
This is not an enhancement and should be given the WONTFIX status.
Re-read the excerpt from the F77 standard that I quoted. If it
is not an outright error, then consider the implications that
this so-called enhancement will have on optimizing DO-loops.
Resolving as WONTFIX, as agreed. There realy isn't a good reason
to support this.