From 89097cd0d602d233c8deddd443ba4baf0f147aef Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Thu, 24 Dec 2015 09:15:27 -0800
Subject: [PATCH] Use setexception to raise the inexact exception for %expm1.

---
 src/lisp/s_expm1.c | 4 ++--
 tests/fdlibm.lisp  | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/lisp/s_expm1.c b/src/lisp/s_expm1.c
index 4e9bae817..64ee69acc 100644
--- a/src/lisp/s_expm1.c
+++ b/src/lisp/s_expm1.c
@@ -160,8 +160,8 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
                 
 	    }
 	    if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */
-		if(x+tiny<0.0)		/* raise inexact */
-		return tiny-one;	/* return -1 */
+                fdlibm_setexception(x, FDLIBM_INEXACT);
+		return tiny - one;
 	    }
 	}
 
diff --git a/tests/fdlibm.lisp b/tests/fdlibm.lisp
index 16c3be43d..5bde0cfdc 100644
--- a/tests/fdlibm.lisp
+++ b/tests/fdlibm.lisp
@@ -163,7 +163,12 @@
 		 (kernel:%expm1 709.8d0))
     )
   (kernel::with-float-traps-masked (:invalid)
-    (assert-true (ext::float-nan-p (kernel:%expm1 *snan*)))))
+    (assert-true (ext::float-nan-p (kernel:%expm1 *snan*))))
+  ;; expm1(x) = -1 for x < -56*log(2), signaling inexact
+  (let ((x (* -57 (log 2d0))))
+    (with-inexact-exception-enabled
+	(assert-error 'floating-point-inexact
+		      (kernel:%expm1 x)))))
 
 (define-test %log1p.exceptions
   (:tag :fdlibm)
-- 
GitLab