我只是使用 gfortran 4.1.2 和 gfortran 4.8.0 来编译以下简单代码:
function foo(a, b) result(res)
integer, intent(in) :: a, b
integer res
res = a+b
end function foo
program test
integer a, b, c
c = foo(a, b)
end program test
gfortran 4.1.2 成功,但 gfortran 4.8.0 给出了奇怪的错误:
test.F90:14.11:
c = foo(a, b)
1
Error: Return type mismatch of function 'foo' at (1) (REAL(4)/INTEGER(4))
任何想法?