From: stassats <sta...@us...> - 2017-11-13 19:41:08
|
The branch "master" has been updated in SBCL: via 78e5ccc6df3df241c89e2218a8b0a103705366c2 (commit) from 4e903c1779aee57217c75c4b81138a2325816e81 (commit) - Log ----------------------------------------------------------------- commit 78e5ccc6df3df241c89e2218a8b0a103705366c2 Author: Stas Boukarev <sta...@gm...> Date: Mon Nov 13 22:31:36 2017 +0300 Fix INTERVAL-DIV with a zero bound. It used to work properly but 425dd2dc04e5069689af53adfbef2671b7c1ca48 had removed the case handling zero numbers because the original code was losing signed zeros. Roll back the original code and don't lose signs. Fixes lp#1731975 --- src/compiler/srctran.lisp | 3 +++ tests/compiler-2.pure.lisp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/compiler/srctran.lisp b/src/compiler/srctran.lisp index ee309a6..32c0da7 100644 --- a/src/compiler/srctran.lisp +++ b/src/compiler/srctran.lisp @@ -945,6 +945,9 @@ ((zerop (type-bound-number y)) ;; Divide by zero means result is infinity nil) + ((and (numberp x) (zerop x)) + ;; Zero divided by anything is zero, but don't lose the sign + (/ x (signum (type-bound-number y)))) (t (bound-binop / x y))))) (let ((top-range (interval-range-info top)) diff --git a/tests/compiler-2.pure.lisp b/tests/compiler-2.pure.lisp index 38184c5..e2858df 100644 --- a/tests/compiler-2.pure.lisp +++ b/tests/compiler-2.pure.lisp @@ -549,3 +549,10 @@ (return-from b3 a)))) (unwind-protect x))))))) ((321) 321))) + +(with-test (:name :interval-div-zero) + (checked-compile-and-assert (:optimize :safe) + `(lambda (x y) + (truncate (the (integer 0 0) x) + (the (rational (1) (2)) y))) + ((0 3/2) (values 0 0)))) ----------------------------------------------------------------------- hooks/post-receive -- SBCL |