(j3.2006) Fw: a question on MERGE and expression evaluation
Jim Xia
jimxia
Thu Nov 18 15:08:27 EST 2010
----- Forwarded by Jim Xia/Toronto/IBM on 11/18/2010 03:08 PM -----
From:
Jim Xia/Toronto/IBM
To:
j3-bounces at j3-fortran.org
Date:
11/18/2010 02:46 PM
Subject:
a question on MERGE and expression evaluation
Hi
We have a piece of code that a user claims should result in a
divide-by-zero exception.
real a(10), y(10)
a = 0.0
y = merge(1.0/a, 0.0, a>0.0)
print *, y
end
None of the compilers I have tried (XLF, NAG and ifort) result in
exception. The standard is also conflicting in saying whether or not
1.0/a should be evaluated at the function invocation time.
Here are some quoted text from F08
12.5.3 seems to say 1.0/a should be evaluated at the function call.
13.2.3 seems to suggest 1.0/a need not to be evaluated since evaluation
with undefined value can result in side-effects.
Although I'm taking the 13.2.3 as a strong argument, F03 indeed spells out
the intention of omitting evaluation of actual argument in Annex C (C 9.5)
However, that section is deleted in F08.
So the question is: should 1.0/a be evaluated upon the function call to
MERGE()?
Cheers,
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/3e90056a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 8382 bytes
Desc: not available
URL: <http://j3-fortran.org/pipermail/j3/attachments/20101118/3e90056a/attachment-0003.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 7109 bytes
Desc: not available
URL: <http://j3-fortran.org/pipermail/j3/attachments/20101118/3e90056a/attachment-0004.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 16392 bytes
Desc: not available
URL: <http://j3-fortran.org/pipermail/j3/attachments/20101118/3e90056a/attachment-0005.gif>
More information about the J3
mailing list