From jkr@jkr.cc.rl.ac.uk  Wed Feb 28 16:57:37 2001
Received: from nameserv.rl.ac.uk (nameserv.rl.ac.uk [130.246.135.129])
	by dkuug.dk (8.9.2/8.9.2) with ESMTP id QAA24111
	for <SC22WG5@dkuug.dk>; Wed, 28 Feb 2001 16:57:36 +0100 (CET)
	(envelope-from jkr@jkr.cc.rl.ac.uk)
Received: from jkr.cc.rl.ac.uk (jkr.cc.rl.ac.uk [130.246.8.20])
	by nameserv.rl.ac.uk (8.8.8/8.8.8) with ESMTP id PAA30830
	for <SC22WG5@dkuug.dk>; Wed, 28 Feb 2001 15:57:30 GMT
Received: (from jkr@localhost)
	by jkr.cc.rl.ac.uk (8.8.8+Sun/8.8.8) id PAA26509
	for SC22WG5@dkuug.dk; Wed, 28 Feb 2001 15:59:20 GMT
Date: Wed, 28 Feb 2001 15:59:20 GMT
From: John Reid <jkr@rl.ac.uk>
Message-Id: <200102281559.PAA26509@jkr.cc.rl.ac.uk>
To: SC22WG5@dkuug.dk
Subject: Iterpretation 31 (pointer function as actual argument):

draft response
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"


Dear WG5,
         Here is my next draft interpretation response. This is
not a new one. It failed its J3 ballot, but there were 11 YES votes to
5 NO votes. The ballot comments are in 00-329 and are appended for your
convenience.  There is no question that the text of the standard needs
to be edited. I have added an edit without altering the conclusion.

I would appreciate comments before I send it to J3, preferably to me in
private.

Cheers,

John. 

..................................................

NUMBER: 000031
TITLE: Association of pointer function result with INTENT(OUT) dummy
       argument
KEYWORDS: Pointer association, dummy argument association, intent
          attribute
DEFECT TYPE: Clarification
STATUS: J3 consideration in progress

QUESTION:  Consider the following program.

      PROGRAM P
        INTEGER, TARGET :: T

        CALL SUB(FPTR())
      CONTAINS
        FUNCTION FPTR()
          INTEGER, POINTER :: FPTR

          FPTR => T
        END FUNCTION FPTR
        SUBROUTINE SUB(IO)
          INTEGER, INTENT(OUT) :: IO

          IO = 17
        END SUBROUTINE SUB
      END PROGRAM P

According to 12.4.1 [200:30-32],

    "If a dummy argument is not a pointer and the corresponding
     actual argument is a pointer, the actual argument shall be
     currently associated with a target and the dummy argument
     becomes argument associated with that target."

According to 12.4.1 [201:19-21],

    "If a dummy argument has INTENT(OUT) or INTENT(INOUT), the actual
     argument shall be definable."

According to 5.1.2.3 [53:29-31],

    "The INTENT(OUT) attribute specifies that. . . any actual
     argument that becomes associated with such a dummy argument
     shall be definable."

The definition of "definable" supplied in Annex A (the term does not
appear to be defined in normative text) is:

    "A variable is <<definable>> if its value may be changed by the
     appearance of its <name> or <designator> on the left of an
     <assignment statement>."

According to this definition, "definable" is a property of variables
only.  In the example above, the actual argument is not a variable.
However, the actual argument is pointer associated with an object
that is definable.  The text cited from 5.1.2.3 refers to the
"actual argument that becomes associated with the dummy argument",
but the first piece of text cited from 12.4.1 makes it clear that
when the actual argument is a pointer, it is the target with which
it is associated that becomes argument associated with the dummy
argument, and not the actual argument itself.

Was it the intent of the committee that this program should not be
standard-conforming?

ANSWER: 

No, it was not intended that this program be standard conforming.
Unfortunately, the standard does not specify whether an expression that
is not a variable is definable. It was not intended that it be
definable since it is not permitted on the left-hand side of an
assignment statement (7.5.1.1) or in a nullify statement (6.3.2). An
edit makes this clear.

Given this edit, the text quoted above from page 53 leads to the 
conclusion that the program does not conform to the standard. It would
still not conform if the intent declaration were removed since
12.5.2.2 contains the text 
    A dummy data object whose intent is not specified is subject to the
    limitations of the data entity that is the associated actual
    argument.  That is, a reference to the dummy data object may occur
    if the actual argument is defined and the dummy data object may be
    defined if the actual argument is definable.
 
EDIT: 

On page 16, add to the end of the paragraph that is subclause 2.4.3.2
[16:37] 'An expresion is not definable unless it is a variable.'

SUBMITTED BY: Henry Zongaro
HISTORY: 98-177      m146   Submitted
         WG5/N1414          Draft answer
         00-260      m154   Passed by J3 meeting
         00-329      m155   Failed J3 letter ballot

..................................................


           RichB's NO vote on 000031

             See IBM's comments.

           Malcolm's YES comment on 000031

             I disagree with the other comments that the dummy
             argument is argument-associated with something that is
             not an actual argument.  The dummy argument is
             associated with the (value of) the actual argument
             expression.

           Craig's NO vote on 000031

             I agree with Van's comments.

           Kurt's NO vote on 000031

             I agree with Van.  The pointer that is the function
             result is not definable, but the target identified by
             that pointer (in this case, T) _is_ definable.  In the
             example given, the dummy argument is associated with the
             target, not the pointer.

             [The prohibition against a function reference appearing
              on the left hand side of an assignment statement is
              syntactic in nature and has no bearing on this semantic
              question.]

           Van's NO vote on 000031

             I don't know the intent of the committee, but my
             experience in reading the standard is that the area of
             argument association of pointers is murky.  It is my
             preference that a non-pointer dummy argument is
             considered to be associated with a definable actual
             argument if the actual argument is a pointer that is
             associated with a definable target.  The glossary entry
             for "definable" is not normative, and, like Henry, I
             could not find a normative definition for it.  I prefer
             not to depend on non-normative text to resolve an
             interpretation. Henry's arguments concerning the
             relation between the passages he cites from 5.1.2.3 and
             12.4.1 convince me that the example he provides should
             be standard-conforming.  If the dummy argument had the
             pointer attribute, I would accept a conclusion that its
             pointer association status could not be changed, because
             in that case, the actual argument would be a function
             result.

           Henry's NO vote on 000031

             We are inclined to agree with Van Snyder on this
             question.  It is clear that the standard treats
             specially pointers that appear as actual arguments when
             the associated dummy is not a pointer:  the dummy
             becomes argument associated with the target of the
             pointer, not with the actual argument itself.  We agree
             the actual argument is not definable, but that seems
             irrelevant because the entity that is argument
             associated with the target is not the actual argument in
             this case.

             It seems far more likely that the drafters of the
             standard failed to take into account the case of a
             pointer actual argument that corresponds to a nonpointer
             dummy argument when they required that the "actual
             argument shall be definable" in [201:19-21] and
             [53:29-31].

             In fact, the text cited at 5.1.2.3 [53:29-31] is
             particularly troublesome.  To repeat, it states that:

               The INTENT(OUT) attribute specifies that. . . any
               actual argument that becomes associated with such a
               dummy argument shall be definable.

             But in the case of a pointer actual argument that
             corresponds to a nonpointer dummy, there is no actual
             argument associated with the dummy.  The target of the
             pointer is associated with the dummy, but the target
             is not the actual argument.

             We also feel that a normative definition of the term
             "definable" is required.
