procedure pointer problem

I’ve got into a problem when I use procedure pointer to point to a function returning a 64-bit integer. Here is a simple code that reproduces the problem:

module ma
implicit none
integer, parameter :: ki = selected_int_kind(10)
procedure(ma_a), pointer :: ma_p => null()

contains

subroutine ma_init()
implicit none
ma_p => ma_a
end subroutine ma_init

integer(kind = ki) function ma_a()
implicit none
ma_a = 1_ki
end function ma_a

end module ma

program test
use ma
implicit none
call ma_init()
write (*, *) ma_p()
end program test

When I try to compile the above code with pgf90, I get such an error message:

PGF90-S-0155-Illegal POINTER assignment - type mismatch (test.F90: 10)
0 inform, 0 warnings, 1 severes, 0 fatal for ma_init

However, if on line 3 of the code I replace “selected_int_kind(10)” by “selected_int_kind(5)”, then it compiles well and runs well.

I’ve tried this on both pgf90 11.3-0 and 12.5-0, both of which have this problem. I’ve tried gfortran from GNU, which has no such problem.

I wonder if this is a bug of pgf90 or if I missed some restriction imposed by pgf90 but not by gfortran.

Hi wdeng,

I’ve sent this off to our engineers for further investigation (TPR#18974). It does look like a compiler issue, but I’m not sure.

To work around the problem add the “-i8” flag.

Thanks,
Mat

Thank you, Mat. “-i8” does work around the problem.