Thursday, April 19, 2012

Fortran GCC interface compiler bug?

Why does GCC not warn me when I forget to specify the return type of a interface function? For me this behavior seams unexpected. What do you say to this?



This is the test-program (uncoment Line 6 and it works as it should):



program returntest
implicit none
interface
function givehalf(Y)
double precision :: Y
!double precision :: givehalf !<-- Uncomment this line
end function givehalf
end interface
double precision :: temp

temp=givehalf(5.151515d0)
print*, 'result= ',temp

end program returntest

function givehalf(Y)
implicit none
double precision :: Y
double precision :: givehalf

print*, 'Y= ',Y
givehalf=Y/2.0d0
print*, 'return Y/2',givehalf

return
end function givehalf


The result is this:



user@bapf028dl:/media/disk> gfortran44 -Wall return-test.f90
user@bapf028dl:/media/disk> ./a.out
Y= 5.1515149999999998
return Y/2 2.5757574999999999
result= -1.0579199790954590
user@bapf028dl:/media/disk> ifort return-test.f90
user@bapf028dl:/media/disk> ./a.out
Y= 5.15151500000000
return Y/2 2.57575750000000
result= 2.57575750350952




No comments:

Post a Comment