This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: FP comparisons, C, X86, and NaN's
- From: Chris Lattner <sabre at nondot dot org>
- To: Gabriel Dos Reis <gdr at acm dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 20 Jun 2004 02:25:16 -0500 (CDT)
- Subject: Re: FP comparisons, C, X86, and NaN's
On Sun, 20 Jun 2004, Gabriel Dos Reis wrote:
> > I'm trying to understand the standards relating to floating point
> > comparisons in C, particularly with respect to NaN's. From my
> > interpretation of the whole mess, in C99, standard relational operations
> > (like X < Y) should trap on NaN's, including SNaNs.
>
> QNaNs don't trap, but would obey non-standard logic. SNaNs would
> trap. More specifically, the C99 standard says:
> 5.2.4.2.2/3
That is an interesting section, thanks for pointing it out.
> > 2. C does not define whether or not standard relational operations trap.
> > If this is the case, there is no bug in GCC.
So you are saying that this is the case: it is undefined whether an
implementation traps on a comparison with nans? This is my interpretation
of this passage:
> -- is true. Relational operators may raise the
> ``invalid'' floating-point exception when argument values
> are NaNs.
I just want to make sure that I'm intepreting things correctly.
Thanks for the input!
-Chris
--
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/