[PATCH] D121306: [Sema] add warning for tautological FP compare with literal

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 24 11:11:24 PDT 2022


efriedma added a comment.

In D121306#3405824 <https://reviews.llvm.org/D121306#3405824>, @alexfh wrote:

> What's the right fix for this warning, using a literal of the same floating point type?

Probably? Depends on why you're trying to use equality on floating-point numbers; "x == 0.3" is inherently a bit suspicious.

> Did you consider adding a fixit hint to the diagnostic?

A fixit to do what?  Replacing the comparison with a literal "true"/"false" would probably be unwelcome.  And I don't really want a "fixit" to change the meaning of well-defined code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121306/new/

https://reviews.llvm.org/D121306



More information about the cfe-commits mailing list