AaronBallman wrote:

> In my opinion, `0` and `INFINITY` should be allowed by default with this 
> `-Wfloat-equal`, since you commonly want to guard against those values. 
> Additionally, we could have a flag that restricts the use of `0`. As for 
> other float values (other than `0` and `INFINITY`), maybe we should not allow 
> them by default and provide a flag to allow exact float values, this way, 
> people who intend to compare to the same bit pattern can still do so.

I think it's useful to find *all* direct comparisons of floating-point types 
regardless of value, which is the behavior of `-Wfloat-equal` in GCC. It's not 
that the comparison itself is invalid, it's that it's pointing out a potential 
algorithmic issue with the computations leading up to the comparison. e.g., 
https://godbolt.org/z/d69drsM95 But given that this has been Clang's behavior 
with this diagnostic for almost 20 years, I expect changing Clang to match GCC 
would be too disruptive. That suggests we need a new warning group, but naming 
the group will be a challenge.

https://github.com/llvm/llvm-project/pull/207288
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to