Kenneth_Smith
Joined: 18 May 2012 Posts: 797 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Fri Mar 21, 2025 1:48 am Post subject: Interface bug? |
|
|
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.
Code: | 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 |
|
|