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
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

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.

-Mat

1 Like

Hi Paul,

TPR #31247 should be fixed in our 23.5 release.

% nvfortran -c test2.f90 -V23.3
NVFORTRAN-W-0194-INTENT(IN) argument cannot be defined - a (test2.f90: 6)
  0 inform,   1 warnings,   0 severes, 0 fatal for foo
% nvfortran -c test2.f90 -V23.5
%
  • Mat
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.