Newsgroups: comp.std.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: floating point constant folding
Message-ID: <1990Nov13.174025.1520@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <8191@star.cs.vu.nl>
Date: Tue, 13 Nov 90 17:40:25 GMT

In article <8191@star.cs.vu.nl> eck@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@zoo.toronto.edu   utzoo!henry
