Silverfrost Forums

Welcome to our forums

Interface bug?

21 Mar 2025 12:48 #31997

The following code compiles without error using FTN95.

In the main program the call to S1 (where the function F is an argument) returns the expected results.

The call to S2 also has the function F as an argument, and S2 itself calls S1 (passing F as an argument of this call to S1).

In this case, an access violation occurs when F is called within S1 i.e. when S1 has been called by S2.

I believe the required interfaces are in place, so I think this may be a bug with FTN95. This code runs successfully with other compilers.

module demo
implicit none
contains  
 
  subroutine s1(f,x,r)
  interface
    function f(x) result(y)
      implicit none
      real x, y
      end function f
  end interface
  real x, r
    r = f(x)       ! Access violation occurs here when S1 is CALLed from S2
  end subroutine s1

  subroutine s2(f,x,r)
  interface
    function f(x) result(y)
      implicit none
      real x, y
      end function f
  end interface
  real x, r
    call s1(f,x,r)  
  end subroutine s2
  
end module demo

program p
use demo
implicit none
interface
  function f(x) result(y)
    implicit none
    real x, y
    end function f
end interface
real x, r
  x = 2.0
  call s1(f,x,r)         ! This works
  print*, 'r =    ', r
  call s2(f,x,r)         ! This fails with FTN95
  print*, 'r =    ', r
end program p


function f(x) result(y)
implicit none
real x, y
  y = x*x
end function f
21 Mar 2025 7:01 #31999

Thanks Ken. I have logged this for investigation.

14 May 2025 5:24 #32108

This failure has now been fixed for the next release of FTN95.

Please login to reply.