[PATCH] D88238: [APFloat] convert SNaN to QNaN in convert() and raise Invalid signal

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 12:18:30 PDT 2020


spatel added a comment.

In D88238#2301206 <https://reviews.llvm.org/D88238#2301206>, @rjmccall wrote:

> The change to ExprConstant should be a different patch, with a test that we can still constant-evaluate something else that results in opInvalid (I assume there must be something?).

I can't find an existing path to expose that difference in a test. We use checkFloatingPointResult() in 2 places: FP binops and FP cast. Without this patch, casting never sets opInvalidOp. Binops have a variety of means to create a NaN + opInvalidOp, but that path is gated by:

  // [expr.pre]p4:
  //   If during the evaluation of an expression, the result is not
  //   mathematically defined [...], the behavior is undefined.
  // FIXME: C++ rules require us to not conform to IEEE 754 here.
  if (LHS.isNaN()) {
    Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << LHS.isNaN();
    return Info.noteUndefinedBehavior();
  }
  return checkFloatingPointResult(Info, E, St);

So unless there's a way to raise opInvalidOp without also creating a NaN, we're stuck?


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

https://reviews.llvm.org/D88238



More information about the llvm-commits mailing list