On 10/30/2009 01:44 AM, Van Snyder wrote:
>> The -finit-real=NAN is less than optimally useful, because it
>> initializes real variables to a quiet NAN. It would be more useful if
>> it initialized them to a signaling NAN. Better yet would be to allow
>> selecting which kind of NAN is used to initialize real variables, say
>> -finit-real=qNAN or -finit-real=sNAN.
>>
The problem was that the internal representation in mpfr does not make
the distinction. (Nor did IEEE 754:1985 state how to represent sNaN
bitwiese; IEEE 754:2008 does.) And as mpfr is used to store
floating-point literals in the compiler front end ...
The sNaN support is new in GCC 4.5, see
http://gcc.gnu.org/gcc-4.5/changes.htmlThe sNaN state is now saved outside of mpfr, which means that doing e.g.
"1 + sNaN" evaluates to "qNaN" (compile time simplification) while "a
+ sNaN" gives a SIGFPE if the expression is evaluated at run time. As
written in the release notes, one needs to enable FPE otherwise also
sNaN are quiet.
Tobias