https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89646

            Bug ID: 89646
           Summary: Spurious actual argument might interfere warning
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ian_harvey at bigpond dot com
  Target Milestone: ---

The following:

  MODULE m
    IMPLICIT NONE
    TYPE :: t
    END TYPE t
  CONTAINS
    SUBROUTINE s
      ! To reproduce, both actual arguments must be TARGET, 
      ! both arguments must be of derived type.
      TYPE(t), TARGET :: a(5)
      TYPE(t), TARGET :: b(5)

      CALL move(a, b)
    END SUBROUTINE s

    ! To reproduce, called procedure must be elemental.
    ELEMENTAL SUBROUTINE move(from, to)
      TYPE(t), INTENT(INOUT) :: from
      TYPE(t), INTENT(OUT) :: to
    END SUBROUTINE move
  END MODULE m

when compiled with recent trunk (r26545) gives the following spurious warnings:

  argument-interfereb.f90:12:14-17:

     12 |     CALL move(a, b)
        |              1  2
  Warning: INTENT(INOUT) actual argument at (1) might interfere with actual
argument at (2).
  argument-interfereb.f90:12:14-17:

     12 |     CALL move(a, b)
        |              2  1
  Warning: INTENT(OUT) actual argument at (1) might interfere with actual
argument at (2).

I suspect that the compiler is trying to warn me about potential aliasing given
the TARGET attribute on the actual arguments, but there is no such aliasing in
this example, and the details required to trigger the warning (arguments must
be derived type, procedure must be elemental) are too specific for this warning
to be useful or intended.

Reply via email to