Incorrect warning for INTENT(IN) pointer to TYPE in nvfortran@22.1

x86 nvfortran 22.1 incorrectly issues a warning for the code:

module bar
  type, bind(c) :: a_struct
     integer :: field
  end type a_struct
  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 … 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 (

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.


I’m not familiar with the section of the Fortran standard to say if the warning is valid or not so added TPR #31247 and asked engineering to investigate.


1 Like