https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79553

            Bug ID: 79553
           Summary: Infinite gfortran loop on invalid code with procedures
                    parameters
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luthaf at luthaf dot fr
  Target Milestone: ---

Trying to compile the following (invalid) code make the compiler send errors
and then enter in infinite loop:

```
program error
    implicit none
    ! Define a procedure with the same name as its type
    procedure(procname), pointer :: procname

    interface
        subroutine procname(a)
            implicit none
            integer :: a
        end subroutine
    end interface
contains

    ! And use it as an argument for another procedure
    subroutine use_procname(proc)
        procedure(procname) :: proc
    end subroutine
end program
```

The compiler output before entering the loop is not really helpful in
determining the cause of the error:

```
loop.f90:7:30:

         subroutine procname(a)
                              1
Error: Symbol 'procname' at (1) already has an explicit interface
loop.f90:8:25:

             implicit none
                         1
Error: Unexpected IMPLICIT NONE statement in INTERFACE block at (1)
loop.f90:9:24:

             integer :: a
                        1
Error: Unexpected data declaration statement in INTERFACE block at (1)
loop.f90:10:11:

         end subroutine
           1
Error: Expecting END INTERFACE statement at (1)
```

Removing the soubroutine make the error clearer (PROCEDURE 'procname' at (1)
may not be used as its own interface):

```
loop.f90:7:30:

         subroutine procname(a)
                              1
Error: Symbol 'procname' at (1) already has an explicit interface
loop.f90:8:25:

             implicit none
                         1
Error: Unexpected IMPLICIT NONE statement in INTERFACE block at (1)
loop.f90:9:24:

             integer :: a
                        1
Error: Unexpected data declaration statement in INTERFACE block at (1)
loop.f90:10:11:

         end subroutine
           1
Error: Expecting END INTERFACE statement at (1)
loop.f90:7:27:

         subroutine procname(a)
                           1
Error: PROCEDURE 'procname' at (1) may not be used as its own interface
```

Reply via email to