(j3.2006) actual arguments of intrinsic functions

Robert Corbett Robert.Corbett at Sun.COM
Sun May 10 05:49:42 EDT 2009


Last Friday, Van Snyder asked if the intrinsic function LEN could
take a function name that was specified to have CHARACTER type as
its actual argument.  My recollection was that the actual arguments
of intrinsic functions other than ASSOCIATED were required to be
data entities, and so a function name would not be allowed as an
actual argument to an intrinsic function.  Later that day, I
checked the Fortran standards and found a requirement to that
effect in the FORTRAN 77 standard (Section 15.3.2), but I found
no such restriction in any other version of the standard.

Tonight I ran experiments using a variety of compilers.  The number
of compilers I used in my tests has been reduced from the number I
used to use because some licenses have expired, but even so the
variations in the results have been surprising.  I found compilers
that allowed LEN to be called with a function name as its actual
argument, and I found compilers that did not.  I found one compiler
that compiled and ran the following program:

       PROGRAM MAIN
         INTRINSIC DSQRT
         PRINT *, DABS(DSQRT)
       END

The result was garbage.  I tried a variant of that program that
used ABS instead of DABS first.  That variant failed to compile
because the compiler could not resolve the generic.

Does the standard impose restrictions on the actual arguments of
intrinsic functions that I overlooked?  The standard says that the
dummy arguments of the intrinsic functions all have INTENT(IN).
Could that be construed to mean that the corresponding actual
arguments must be data entites except in the case of the intrinsic
function ASSOCIATED?

Bob Corbett


More information about the J3 mailing list