x86 nvfortran 22.1 incorrectly issues a warning for the code:
module bar
type, bind(c) :: a_struct
integer :: field
end type a_struct
contains
subroutine foo(a)
type(a_struct), pointer, intent(in) :: a
a%field = 1
end subroutine foo
end module bar
The warning is:
NVFORTRAN-W-0194-INTENT(IN) argument cannot be defined - a (ptr_intent.f90: 6)
0 inform, 1 warnings, 0 severes, 0 fatal for foo
Section 8.5.10 of the Fortran 2018 standard (draft),
C844: A pointer with the INTENT (IN) attribute shall not appear in a pointer association context (19.6.8).
and
8.5.10.2: … The INTENT (IN) attribute for a pointer dummy argument specifies that during the invocation and execution of the procedure its association shall not be changed except that it may become undefined if the target is deallocated other than through the pointer (19.5.2.5).
The association of the pointer does not change in procedure foo
, so it should be accepted without warning. Note that if the pointer dummy argument is to an intrinsic type, say INTEGER, the compiler does not issue the warning.
Thanks!
Paul