[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 10:42:29 PST 2024


================
@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup<DiagGroup<"float-equal">>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 in fast floating point mode">,
----------------
andykaylor wrote:

Maybe this message should either be more specific or not mention the floating point mode at all. Since this will trigger with just "-fno-honor-nans" or "-fno-honor-infinities" the message is somewhat off target. I guess either of these is a fast floating point mode, but the message makes me think of full fast-math mode, which isn't necessarily the case.

```suggestion
  "explicit comparison with %0 when the program is assumed to not use or produce %0">,
```

https://github.com/llvm/llvm-project/pull/76873


More information about the cfe-commits mailing list