[J3] An inquiry about the extension with pointer function reference introduced in Fortran 2008

Bill Long longb at cray.com
Mon Mar 8 13:08:40 UTC 2021


I guess I don't see a problem with the program.  I see it compile with no error messages, and “execute”.  Though the code reduces to (interal code-gen representation) 

 program $main
   14.       x[0] = 1 + x[0]
   14.       (1,x)[0] = 1 + (1,x)[0]
   14.       (2,x)[0] = 1 + (2,x)[0]
   15.       call _end
  
and hence actually does nothing of external consequence.

Cheers,
Bill



> On Mar 7, 2021, at 6:20 PM, Vipul Parekh via J3 <j3 at mailman.j3-fortran.org> wrote:
> 
> The Introduction section in the 10-007r1 document toward Fortran 2008 states, "A pointer function reference can denote a variable in any variable definition context."
> 
> Does the following then conform?
> 
> --- begin program ---
> 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 
> --- end program ---
> 
> Thank you,
> Vipul Parekh

Bill Long                                                                       longb at hpe.com
Engineer/Master , Fortran Technical Support &   voice:  651-605-9024
Bioinformatics Software Development                      fax:  651-605-9143
Hewlett Packard Enterprise/ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425






More information about the J3 mailing list