[PATCH] D109925: [AST] add warnings for out-of-bounds FP values when using relaxed FP math compile flags

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 20 02:20:55 PDT 2021


sepavloff added a comment.

I don't think the constant evaluator is a right place for such warnings. The option `-ffast-math` is a hint to the compiler, which, in particular, tells that no operation on Nans/Infs take place. It allows a compiler to generate better code. None is pertinent for the constant evaluator, as it already has all information necessary for the evaluation and it does not generate any code. It does not make sense to add a new mode for constant evaluation as well. To make the warnings useful you probably need to check if a constant value is an operand of an arithmetic operation.



================
Comment at: clang/test/AST/warn-fp-values.c:49
+double neg_zero_literal() {
+  return -0.0; // shows warning if compile continues with -emit-llvm
+}
----------------
`-ffast-math` does not prohibit using negative zero, it only treat it identically to positive zero.


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

https://reviews.llvm.org/D109925



More information about the cfe-commits mailing list