(j3.2006) ASSOCIATED

Robert Corbett Robert.Corbett at Sun.COM
Fri Mar 12 21:10:54 EST 2010


Bill Long wrote:
> 
> 
> Robert Corbett wrote:
> 
>>
>> I see now that fixing the specifications of the intrinsic functions is
>> going to be a lot of fun.
>>
>> I do not think that the authors of the standard intended it to be
>> impossible for cases (vi) or (vii) to occur.  Under your interpretation,
>> the program
>>
>>        PROGRAM MAIN
>>          POINTER P, Q
>>          REAL X
>>          TARGET X
>>          P => X
>>          NULLIFY(Q)
>>          PRINT *, ASSOCIATED(P, Q)
>>        END
>>
>> should print " T" because P is associated and Q, which is argument
>> associated with the dummy argument TARGET of ASSOCIATED, is not
>> associated and therefore the dummy argument TARGET is "not present."
>> I just compiled and ran that program using three different compilers.
>> All three runs printed " F".
>>
> 
> Nice example. I tried 5 compilers and got F:5, T:0.  And I believe this 
> is what is intended. ASSOCIATED looks like a case where we need to have 
> 2 forms and not identify the TARGET argument as optional.

I realized while driving home from work this morning that the two
signature specification of ASSOCIATED is not equivalent to the
specification of ASSOCIATED in Fortran 2003.  In Fortran 2003,
assuming "absent" means "not present", the following program is
standard conformant:

       SUBROUTINE SUBR(P, Q)
         POINTER P, Q
         OPTIONAL Q
         PRINT *, ASSOCIATED(P, Q)
       END

       PROGRAM MAIN
         INTERFACE
           SUBROUTINE SUBR(P, Q)
             POINTER P, Q
             OPTIONAL Q
           END SUBROUTINE
         END INTERFACE
         POINTER P
         TARGET X
         P => X
         CALL SUBR(P)
       END

Under the two signature specification, the function reference is not
permitted because Q is not present in SUBR.

The program gets a segmentation violation when run after being compiled
with the compilers available to me, but that does not mean it is not a
standard conformant program.

Bob Corbett


More information about the J3 mailing list