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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[F08] A pointer function    |[F2008][F08] A pointer
                   |reference can denote a      |function reference can
                   |variable in any variable    |denote a variable in any
                   |definition context.         |variable definition
                   |                            |context.
                 CC|                            |burnus at gcc dot gnu.org
           Keywords|                            |rejects-valid

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Also popped up today by a post by Vipul Parekh to the J3 mailing list - and
everyone regarded it as valid.


The following program uses 'get()' as variable (referencing pointer-returning
function in a nonpointer context) – and gfortran rejects it with:

   14 |    call increment( get() )
      |                   1
Error: ‘get’ in variable definition context (actual argument to INTENT =
OUT/INOUT) at (1) is not a variable



F2018 reference:

R1524 actual-arg is expr
                 or variable
R902 variable is designator
              or function-reference
C902 (R902) function-reference shall have a data pointer result



module m
   integer, target :: x(3) = [ 1, 2, 3 ]
contains
   function get() result(p)
      integer, pointer :: p(:)
      p => x
   end function get
   subroutine increment(n)
      integer, intent(inout) :: n(:)
      n = n + 1
   end subroutine increment  
end module m
   use m
   call increment( get() )
end

Reply via email to