Vipul Parekh wrote:
> Consider the following simple program:
>
> integer, pointer :: x => null()
> integer, target :: y = 42
> call sub1( x, y )
> print *, "After sub1: associated(x)? ", associated(x), "; expected is T"
> call sub2( x )
> print *, "After sub2: associated(x)? ", associated(x), "; expected is ?"
> contains
> subroutine sub1( ptr, tgt )
> integer, pointer, intent(out) :: ptr
> integer, target, intent(in) :: tgt
> ptr => tgt
> end subroutine
> subroutine sub2( ptr, tgt )
> integer, pointer, intent(out) :: ptr
> integer, target, intent(in), optional :: tgt
> if ( present(tgt) ) ptr => tgt
> end subroutine
> end
>
> What should be the association status of actual argument x following
> the invocation of the subprogram sub2 per current Fortran standard?
> Is it processor-dependent?
No, it is undefined.
> Readers will note the standard says in section 12.5.2.7 Pointer dummy
> variables, para 4 of 10-007r1, "If the dummy argument has INTENT
> (OUT), the pointer association status of the actual argument becomes
> undefined on invocation of the procedure." If the subprogram then
> fails to associate the dummy argument with a valid target, does the
> actual argument remain undefined upon procedure exit?
Yes, of course it does. The program does not conform to the standard
because the main argument of ASSOCIATED is required to be defined.
John Reid.
########################################################################
To unsubscribe from the COMP-FORTRAN-90 list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/webadmin?SUBED1=COMP-FORTRAN-90&A=1
|