Hello,
the following code shows that nvfortran IMHO accepts invalid code and may produce surprising results:
program test
implicit none
real, pointer :: p(:), r(:)
allocate (r(5))
p => r
call chk1 (p, (r)) ! Illegal
call chk2 (p, (r)) ! Questionable
contains
subroutine chk1 (ptr, tgt)
real, pointer, intent(in) :: ptr(:)
real, pointer, intent(in) :: tgt(:)
print *, "chk1:", associated (ptr, tgt)
end subroutine chk1
subroutine chk2 (ptr, tgt)
real, pointer, intent(in) :: ptr(:)
real, target, intent(in) :: tgt(:)
print *, "chk2:", associated (ptr, tgt)
end subroutine chk2
end program test
The line marked “illegal” is rejected by Intel, NAG, and other compilers.
Nvidia 22.1 prints for this example:
chk1: T
chk2: T
After commenting the illegal line, e.g. Intel prints:
chk2: F
It appears that the handling of effective arguments seems to differ between compilers, and I believe that the call to chk1 as above should be rejected. Intel says:
nvidia-effective-arg.f90(6): error #7496: A non-pointer actual argument shall have a TARGET attribute when associated with a pointer dummy argument. [R]
call chk1 (p, (r)) ! Illegal
-----------------^
compilation aborted for nvidia-effective-arg.f90 (code 1)
Thanks,
Harald