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

            Bug ID: 90112
           Summary: internal procedure using module procedure instead of
                    "sibling" internal procedure
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jellby at yahoo dot com
  Target Milestone: ---

In some cases an internal procedure will use a module procedure instead of
another internal procedure (in the same host unit) with the same name. In the
example below, R(x) calls f(x), but it uses the module's f(x) instead of the
one internal to g(x) (as probably intended).

module test_functions

contains

subroutine f(x)
  implicit none
  real, intent(inout) :: x
  x = 2 * x
end subroutine f

subroutine g(x)
  implicit none
  real, intent(inout) :: x
  call R(x)
  contains
    subroutine R(x)
      implicit none
      real, intent(inout) :: x
      call f(x)
    end subroutine R
    subroutine f(x)
      implicit none
      real, intent(inout) :: x
      x = 3 * x
    end subroutine f
  end subroutine g
end module

program scope
  use test_functions
  real :: x = 3.0, y = 3.0
  call f(x)
  call g(y)
  write(*, *) x, y
end program


Compiling and running with gfortran 5.4, 7.4, 8.1, gives:

   6.00000000       6.00000000

Compiling and running with ifort 18.0 gives:

   6.000000       9.000000    


This does not happen if f(x) is a function instead of a subroutine, or if the
call to f(x) is made directly in g(x) rather than in R(x).

Reply via email to