https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110477

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Peter Dimov from comment #1)
> Looks like a duplicate of
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108742 and is fixed by casting
> the rhs to (float),

Yes, with -fexcess-precision=standard removal of excess precision only occurs
when assigning to an lvalue or with an explicit cast, not for the equality
comparison.  An even simpler version is:

double f = 2.1;
assert( f == 2.1 ); // fails

The value f has no excess precision bits, but the literal 2.1 is evaluated as
an 80-bit float. The comparison promotes f to the type of the rhs, but it's
lost its excess precision, so we're effectively doing (double)2.1L == 2.1L and
that's false.

> but any ordinary programmer would be baffled.

Yes, very much so.


(In reply to Peter Dimov from comment #3)
> That's true, but the normal expectation of anyone using
> -fexcess-precision=standard would be for it to apply consistently everywhere
> (that is, as if FLT_EVAL_METHOD is 0.)
> 
> Of course given that FLT_EVAL_METHOD is in a header, so unaffected by -f
> options, it's not clear what can be done here.

I think the rationale is that without -fexcess-precision=standard we do not
correctly respect FLT_EVAL_METHOD, so its value doesn't matter. With
-fexcess-precision=standard we do respect it ... with confusing consequences.

The solution is to kill i387 ;-)

-m32 -mfpmath=sse gives more sensible results.

Reply via email to