Floating point performance issue

David Brown david.brown@hesbynett.no
Wed Dec 21 02:19:00 GMT 2011


On 21/12/11 01:27, Miles Bader wrote:
> David Brown<david@westcontrol.com>  writes:
>> Making "-Wfloat-equal" a default flag would eliminate many of these
>> mistakes.
>
> It also results in false positives, so it shouldn't be on by default.
>
> [E.g. "float x = 0;  .... y = x; ... if (y == 0) ..." should not result
> in a warning.]
>
> -Miles
>

I gather (from the bug report mentioned by Vincent Lefevre) that code 
like this will not always give the result you expect - so the compiler 
should definitely warn in such cases.  (Alternatively the compiler could 
be changed so that such code is always consistent regardless of 
architecture, floating point options, and optimisation options - I 
suspect giving a warning is easier.)

mvh.,

David



More information about the Gcc-help mailing list