llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

APFloat does not correctly handle signaling NaN

Open delcypher opened this issue 10 years ago • 2 comments

Bugzilla Link 30781
Resolution FIXED
Resolved on Jan 21, 2020 11:54
Version trunk
OS Linux
CC @andykaylor,@ekatz,@hfinkel,@RKSimon,@gottesmm
Fixed by commit(s) rG0b336b6048ae

Extended Description

According to IEEE-754 2008 (7.2 Invalid operation) "any general-computational or signaling-computational operation on a signaling NaN" should generate an invalid operation exception and return a quiet NaN.

APFloat is supposed to be IEEE-754 2008 compliant but it does not handle this part of the spec correctly. Currently if it performs an operation on a signaling NaN it returns APFloat::opOK and a signaling NaN. Instead it should return APFloat::opInvalidOp and a quiet NaN.

It appears this limitation is known about because in unittests/ADT/APFloatTest.cpp there is this comment

  // TODOS/NOTES:
  // 1. Since we perform only default exception handling all operations with
  // signaling NaNs should have a result that is a quiet NaN. Currently they
  // return sNaN.

I couldn't find an open bug specifically for this issue so I'm opening this one.

delcypher avatar Oct 25 '16 14:10 delcypher

Fix available in review https://reviews.llvm.org/D69774.

ekatz avatar Nov 06 '19 09:11 ekatz

assigned to @ekatz

delcypher avatar Oct 25 '16 14:10 delcypher