[cfe-commits] r44058 - in /cfe/trunk: Sema/SemaExpr.cpp test/Sema/floating-point-compare.c

Neil Booth neil at daikokuya.co.uk
Wed Nov 14 14:35:06 PST 2007


Chris Lattner wrote:-

> >>The first case still isn't really kosher either, but suppressing
> >>warnings for explicit tests against 0.0 probably will suppress more
> >>false positives than the number of false negatives it will cause.
> >
> >Indeed, and same for 1.0 and -1.0 etc.  All those numbers are exact
> >as written.
> >
> >>I think the second case is far more likely to be an error.
> >
> >3.14159 is not exact as written so would be diagnosed under my
> >proposal.
> 
> This is an interesting proposal.  Is there any way to tell that the  
> value is inexact?

Of course :)  APFloat tells you that in its return value.

It gets hex FP correct always, but in a few cases when the significand
is long it will claim a decimal is inexact when it's exact (because
it's already determined the correctly rounded nearest FP number
regardless of the remaining digits, and so doesn't bother examining them,
essentially).  This would be rare for normal input.  Fixing it is a
straightforward exercise :)

Neil.



More information about the cfe-commits mailing list