floating point constant folding

Henry Spencer henry at zoo.toronto.edu
Wed Nov 14 04:40:25 AEST 1990


In article <8191 at star.cs.vu.nl> eck at cs.vu.nl (Hans van Eck) writes:
>Is it allowed to evaluate constant floating point expressions with greater
>range and precision than that of the execution environment in contexts
>where a constant is not required?
>
>There are unexpected implications of both allowing and disallowing such
>folding, but I cannot find a statement in the standard that unambiguously
>says what a translator may or may not do.

I believe the relevant statement is the "as if" rule discussed in 2.1.2.3:
the compiler can do anything it pleases, provided the observable results
are the same.  Observable results include overflow exceptions and the values
of data items written out to files.  Evaluating constant floating-point
expressions at compile time using different floating-point hardware strikes
me as a minefield of difficulties.
-- 
"I don't *want* to be normal!"         | Henry Spencer at U of Toronto Zoology
"Not to worry."                        |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.std.c mailing list