[cfe-dev] -Wfloat-equal issued too much.
javier_3 at runbox.com
Sun Jun 21 01:02:46 PDT 2015
Before I stop reporting on Clang, just some ideas:
The code at SemaChecking.cpp, function Sema::CheckFloatComparison, issues the warning warn_floatingpoint_eq (-Wfloat-equal) in case of using == or != with floating point operands, but prevents the issuing of the warning in some special cases, among which:
// Special case: check for comparisons against literals that can be exactly
// represented by APFloat.
So if the code reads if(x==0.0F) no warning is issued, but if the user simply writes if(x==0) the warning is issued.
Given that both pieces of code get translated to exactly the same and the user obviously knows what he is doing when writing if(x==0), my point is that in the second case the warning should not be issued too.
I get dozens of annoying warning because of comparisons against zero, but I don't want to turn off that warning because I think it's really meaningful in the other cases, e.g. if(x==y).
Note: I finally turned off that warning, I filled the dignostics output with useless warnings.
More information about the cfe-dev