(j3.2006) Must MERGE evaluate all of its arguments?
Robert Corbett
Robert.Corbett
Wed Jan 28 05:38:55 UTC 2009
The assertion was made on comp.lang.fortran that the intrinic
function MERGE must evaluate all of its arguments. The basis
for the assertion was the following statement regarding
function references given in Section 12.4.2 of the
Fortran 2003 standard:
When it [the function] is invoked, all actual arguments
^^^
are evaluated, then the arguments are associated, and
then the function is executed.
I compiled and ran the program
BLOCKDATA
COMMON I
INTEGER I
DATA I/0/
END
REAL FUNCTION F()
COMMON I
INTEGER I
I = I + 1
F = 1.0
END
REAL FUNCTION G()
COMMON I
INTEGER I
I = I + 2
G = 2.0
END
PROGRAM MAIN
COMMON I
INTRINSIC MERGE
INTEGER I
PRINT '('' '', F3.1)', MERGE(F(), G(), .FALSE.)
PRINT '('' '', I0)', I
END
using four different compilers. With three of the four
compilers, the results were
2.0
2
With the remaining compiler, the result was
2.0
3
Are the three compilers that got the first result not
standard conforming in this regard?
Bob Corbett
More information about the J3
mailing list