(j3.2006) Can we make C1203 item 6 less restrictive?

Van Snyder Van.Snyder
Thu Apr 3 20:10:24 EDT 2014


C1293 at [316:7-19] says (in part)

        "C1293 In a pure subprogram any designator with a base object...
        accessed by use association... shall not be used
        ...
        (6) as an actual argument corresponding to a dummy argument ...
        with the POINTER attribute."

That seems not to be a problem if the referenced procedure has explicit
interface (which C1290 requires) where it is invoked, and is pure (which
C1294 requires) and the dummy argument has INTENT(IN).

Can we replace item (6) with the following?

        (6) as an actual argument corresponding to a dummy argument with
        INTENT(OUT) or INTENT(INOUT), or
        (7) as an actual argument corresponding to a dummy argument with
        the POINTER attribute unless the dummy argument has the
        INTENT(IN) attribute.

Thereby, the INTENT(IN) attribute, together with C1293(2), protect the
dummy argument's target from side-effect tampering.

This was item (10) in the constraint on pages 212-213 of the Fortran 95
standard.  That it could have been less restrictive was not realized
when pointer intents were introduced in 2003.

I got to this question because I need to make a computation using some
elements of a pointer array if the pointer is associated, else a default
value is used.  I needed it at several places in a pure subroutine, so I
wrote a pure internal function:

  pure integer function QN ( QN_s )
    integer, intent(in), pointer :: QN_s(:)
    integer :: N
    qn = -1
    if ( associated(qn_s) ) then
      n = size(qn_s)
      qn = sign(qn(2), qn_s(n) - qn_s((n+1)/2))
    end if
  end function QN

The actual argument to QN was a pointer component of an object accessed
by use association.

This fell afoul of C1293(6) because the dummy argument (necessarily) has
the POINTER attribute.





More information about the J3 mailing list