(j3.2006) Must MERGE evaluate all of its arguments?

Malcolm Cohen malcolm
Wed Jan 28 05:54:21 UTC 2009



Robert Corbett wrote:
> The assertion was made on comp.lang.fortran that the intrinic
> function MERGE must evaluate all of its arguments.
Come on Robert, you know better than that.  Some compilers just 
evaluated a mathematically-equivalent expression instead, as they are 
explicitly allowed to.  Or took advantage of the following explicit licence:

QUOTE:
   "It is not necessary for a processor to evaluate all of the operands 
of an expression, *OR TO EVALUATE ENTIRELY EACH OPERAND*, if the value 
of the expression can be determined otherwise."

It has been said that "otherwise" includes "by divine revelation", but 
even that's not required here.

The program isn't even standard-conforming, since if a function defines 
a variable, and the result of the function wasn't necessary for the 
evaluation of the expression, that variable becomes undefined.  So it is 
printing an undefined variable.

QUOTE:
   "If a statement contains a function reference in a part of an 
expression that need not be evaluated, all entities that would have 
become defined in the execution of that reference become undefined..."


> Are the three compilers that got the first result not
> standard conforming in this regard?
>   
You are just lucky you didn't start WW3!

Cheers,
-- 
.....................Malcolm Cohen, Nihon NAG, Tokyo.





More information about the J3 mailing list