(j3.2006) Fw: a question on MERGE and expression evaluation
Jim Xia
jimxia
Thu Nov 18 21:44:16 UTC 2010
> This question gets asked repeatedly on the j3 email list. The most
> recent reply I found was from Malcolm, in reply to Bob. I'll paste that
> in below.
I'm not convinced that all these answers are correct. The quoted text in
previous replied are from clause 7 (on expression), and what they say is
"you can omit expression evaluation if you're sure what the expression
must be evaluated to". That's about operations evaluation like "expr1
.op. expr2" where you know the evaluation is true by evaluating expr1.
This is not what's happening here: "Merge(1/a, 0.0, a > 0)" is a function
reference, right? And 12.5.3 seems to say 1.0/a should be evaluated at
the function call.
What do we say about this mandate?
Cheers,
However, I do think that an implementation that DOES
evaluate
> all of the arguments first is still standard conforming, so the behavior
> would not be the same in all cases. In the particular example you
> showed, assuming that traps on divide-by-zero are not set, the code
> should be fine. It amounts to merge(infinity, 0, a>0) which would
> evaluate to 0.
>
Jim Xia
XL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444 Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM
http://www.ibm.com/software/awdtools/fortran/xlfortran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://j3-fortran.org/pipermail/j3/attachments/20101118/3b9fff9d/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 10411 bytes
Desc: not available
URL: <http://j3-fortran.org/pipermail/j3/attachments/20101118/3b9fff9d/attachment.gif>
More information about the J3
mailing list