nvfortran does not properly handle the F2008+ interpretation of dummy arguments with pointer,intent(in) attribute. Example code:
program bug integer, pointer :: p(:), q allocate (p(3)) p = [1, 42, 3] ! Argument association which works: call s1 (p(2)) ! This is explained in F2018:18.104.22.168 clause 2 (or F2023:22.214.171.124): ! "... the actual argument shall be a pointer or a valid target ! for the dummy pointer in a pointer assignment statement. ..." q => p(2) ! q is a pointer, p(2) is a valid target call s2 (q) ! q is a pointer call s2 (null()) ! Test: pass NULL() pointer call s2 (p(2)) ! p(2) is still a valid target ! (wrong code with nvfortran -> runtime crash) contains subroutine s1 (x) integer, target :: x print *, "s1: x=", x end subroutine s1 subroutine s2 (x) integer, pointer, intent(in) :: x print *, "s2: associated(x)=", associated (x) if (associated (x)) print *, "s2: x=", x end subroutine s2 end program bug
This crashes at runtime with:
s1: x= 42 s2: associated(x)= T s2: x= 42 s2: associated(x)= F s2: associated(x)= T Segmentation fault (core dumped)
Expected result: the last call should again print:
s2: x= 42
NAG and gfortran do the right thing.