[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 0c5ba41 1/3: Fix two compiler ICEs dealing with nan
From: |
Andrea Corallo |
Subject: |
feature/native-comp 0c5ba41 1/3: Fix two compiler ICEs dealing with nan and infinity |
Date: |
Wed, 3 Mar 2021 14:36:36 -0500 (EST) |
branch: feature/native-comp
commit 0c5ba41b72a19f5353083431a1817d86bc3b7fad
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
Fix two compiler ICEs dealing with nan and infinity
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-=): Don't crash when
truncate fails.
* test/src/comp-test-funcs.el (comp-test-=-nan): Add two functions
to be compiled.
---
lisp/emacs-lisp/comp-cstr.el | 9 ++++++---
test/src/comp-test-funcs.el | 8 ++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 996502b..6a8ec52 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -871,9 +871,12 @@ Non memoized version of `comp-cstr-intersection-no-mem'."
;; precisely as an integer add the integer as well.
(cl-loop
for v in (valset cstr)
- when (and (floatp v)
- (= v (truncate v)))
- do (push (cons (truncate v) (truncate v)) (range cstr)))
+ do
+ (when-let* ((ok (floatp v))
+ (truncated (ignore-error 'overflow-error
+ (truncate v)))
+ (ok (= v truncated)))
+ (push (cons truncated truncated) (range cstr))))
(cl-loop
with vals-to-add
for (l . h) in (range cstr)
diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el
index 5bae743..a465026 100644
--- a/test/src/comp-test-funcs.el
+++ b/test/src/comp-test-funcs.el
@@ -667,6 +667,14 @@
(while (comp-test-no-return-3)
(comp-test-no-return-3))))
+(defun comp-test-=-nan (x)
+ (when (= x 0.0e+NaN)
+ x))
+
+(defun comp-test-=-infinity (x)
+ (when (= x 1.0e+INF)
+ x))
+
(provide 'comp-test-funcs)
;;; comp-test-funcs.el ends here