Bug 20224 - gfortran - flags error on strange, but correct f66 program
Summary: gfortran - flags error on strange, but correct f66 program
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-02-26 17:45 UTC by Dale Ranta
Modified: 2005-05-03 07:04 UTC (History)
1 user (show)

See Also:
Host: powerpc-apple-darwin7.8.0
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-26 18:32:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dale Ranta 2005-02-26 17:45:17 UTC
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
 hi
 hi
[dir:~/tests/gfortran] dir% gfortran -o jump jump.f
 In file jump.f:4

  10  continue                                                          
   1
 In file jump.f:9

                    
                   2
Error: Label at (1) is not in the same block as the GOTO statement at (2)
[dir:~/tests/gfortran] dir% cat jump.f
      program main
      do 20 i=1,2
      go to 30
  10  continue
  20  continue
      stop
  30  continue
      write(*,*) 'hi'
      goto 10
      end
Comment 1 Andrew Pinski 2005-02-26 18:32:23 UTC
Hmm, g77 just warned about it:
t.f: In program `main':
t.f:4: warning:
     10  continue
     1
t.f:9: (continued):
         goto 10
              2
Reference to label at (2) is outside block containing definition at (1)


Confirmed.
Comment 2 kargl 2005-02-26 19:44:07 UTC
This is illegal code with respect to F77.

From ansi-x3dot9-1978-Fortran77.pdf

   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.

I haven't looked in the F2003 standard, but I suspect it is also illegal.
Comment 3 kargl 2005-02-27 00:06:09 UTC
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.
Comment 4 Andrew Pinski 2005-02-27 00:10:13 UTC
(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.

/me hides
Comment 5 Tobias Schlüter 2005-02-27 18:32:14 UTC
Downgrading this to enhancement. 27 years of this not being allowed are a long time.
Comment 6 kargl 2005-02-27 19:49:08 UTC
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.
Comment 7 Thomas Koenig 2005-05-03 07:04:48 UTC
Resolving as WONTFIX, as agreed.  There realy isn't a good reason
to support this.

Thomas