Daniel Kraft wrote:
> *****************************************************************
>
> PROGRAM questionable
> REAL,TARGET :: x
> CALL s1(f(x))
> CALL s2(f(x))
> CALL s3(f(x))
> CONTAINS
> FUNCTION f(a)
> REAL,POINTER :: f
> REAL,TARGET :: a
> f => a
> END FUNCTION
> SUBROUTINE s1(variable)
> variable = 42 ! statement 1
> END SUBROUTINE
> SUBROUTINE s2(variable)
> INTENT(OUT) variable
> variable = 42 ! statement 2
> END SUBROUTINE
> SUBROUTINE s3(targ)
> REAL,TARGET :: targ
> REAL,POINTER :: p
> p => targ
> PRINT *,ASSOCIATED(p,x) ! statement 3
> END SUBROUTINE
> END
>
> statement 2 is rejected as it should be and statement 3 prints True
> which is correct. statement 1 is however not rejected but should be:
>
> 1. The call to s1 is not standard conforming. 5.1.2.7 states
> "If no INTENT attribute is specified for a dummy argument, its use
> is subject to the limitations of the associated actual argument."
> The associated actual argument is the function reference f(x); this
> is an expression, not a variable, and therefore not definable,
> because only variables can be defined (in the sense of being given
> a value, see 2.4.3.1.1 and 2.5.5).
>
> ********************************************************************
In the general case, I know the S1 error is the sort of thing where the
onus is on the user, because the compiler cannot reasonably catch most
instances of it. Is it different for a contained routine, or is this
simply a QofI thing where it's suggested to catch it because it's
theoretically possible to catch it?