J3/11-222
To: J3
From: Malcolm Cohen
Subject: Relational equivalence
Date: 2011 June 30
----------------------------------------------------------------------
NUMBER: F03/0065
TITLE: Relational equivalence
KEYWORDS: Relational equivalence
DEFECT TYPE: Interpretation
STATUS: J3 consideration in progress
QUESTION:
Given
REAL X
X = ... some value ...
may
IF( X+3.0 .EQ. 3.0 )...
be transformed into
IF( X .EQ. 0.0 )...
by the processor?
In Fortran 2003, 7.1.8.5 Evaluation of relational intrinsic operations
says
"Two relational intrinsic operations are relationally equivalent if
their logical values are equal for all possible values of their
primaries."
On a machine where addition of 3.0 to a small value is not exact, the
logical values for X+3.0==3.0 are not the same as X==0.0 for all
possible values of X, therefore it would seem that this transformation
would not be possible.
However, Note 7.22 in Fortran 2003 shows this transformation as being
acceptable.
ANSWER:
No, the transformation is not permitted unless it gives the same
answer for all possible values (of X and X+3.0).
The erroneous example has been removed in Fortran 2008.
EDIT:
None.
SUBMITTED BY: Fred Tydeman
HISTORY: 05-192 m173 F03/0065 submitted
09-150 m187 Passed by J3 meeting
09-187r2 m188 Failed J3 letter ballot #18 09-155
11-nnn m195 Revised answer.
----------------------------------------------------------------------