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

            Bug ID: 77746
           Summary: [5 Regression] Wrong subroutine called, clash of
                    specific procedure name and binding-name
           Product: gcc
           Version: 5.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vladimir.fuka at gmail dot com
  Target Milestone: ---

This program finishes successfully with 4.9 and crashes with 5.3.1

The generic resolution selects wrong procedure. The calling procedure happens
to have the same binding-name as the name of the correct specific procedure and
gets called recursively instead of the correct one.

See also similar: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66695 (I have
already 15 still open bugs in gfortran and this is the 16th!)

Output:

> gfortran-5 bug1.F90 
> ./a.out 
Segmentation fault

> gfortran-5 -fcheck=all bug1.F90 
> ./a.out 
At line 22 of file bug1.F90
Fortran runtime error: Recursive call to nonrecursive procedure 'p_execute'



module first
  private
  public execute

  interface execute
    module procedure random_name
  end interface

contains

  subroutine random_name()
  end subroutine
end module

module test
  use first

  implicit none

contains

  subroutine p_execute(i)  bind(C, name="random_name")
    integer :: i

    call execute()
  end subroutine

end module

  use test
  call p_execute(1)
end

Reply via email to