From: Christophe Rhodes Date: Fri, 30 Jul 2004 10:45:30 +0000 (+0000) Subject: 0.8.13.12: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=ad5cd2538240a4283cb4498b21ff7ab23adcde92;p=sbcl.git 0.8.13.12: Fix for division-of-integer-by-constant-zero bug ... don't perform the 2^k transform for k = -1 (which when rounded to an integer gives zero...) ... tests. --- diff --git a/NEWS b/NEWS index 4f52e72..0e37ace 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ changes in sbcl-0.8.14 relative to sbcl-0.8.13: (reported by Rick Taube) * bug fix: structures defined by WITH-ALIEN can be referred to within other definitions in the same WITH-ALIEN. + * bug fix: division operators (MOD, TRUNCATE and the like) with + constant zero divisors and integer dividends no longer generate + left shifts. changes in sbcl-0.8.13 relative to sbcl-0.8.12: * new feature: SB-PACKAGE-LOCKS. See the "Package Locks" section of diff --git a/src/compiler/aliencomp.lisp b/src/compiler/aliencomp.lisp index 56ff0f3..5ff9427 100644 --- a/src/compiler/aliencomp.lisp +++ b/src/compiler/aliencomp.lisp @@ -565,7 +565,7 @@ (give-up-ir1-transform)) (let* ((denominator (lvar-value denominator)) (bits (1- (integer-length denominator)))) - (unless (= (ash 1 bits) denominator) + (unless (and (> denominator 0) (= (ash 1 bits) denominator)) (give-up-ir1-transform)) (let ((alignment (count-low-order-zeros numerator))) (unless (>= alignment bits) diff --git a/src/compiler/srctran.lisp b/src/compiler/srctran.lisp index cbc59ca..e4084c3 100644 --- a/src/compiler/srctran.lisp +++ b/src/compiler/srctran.lisp @@ -2665,7 +2665,7 @@ (let* ((y (lvar-value y)) (y-abs (abs y)) (len (1- (integer-length y-abs)))) - (unless (= y-abs (ash 1 len)) + (unless (and (> y-abs 0) (= y-abs (ash 1 len))) (give-up-ir1-transform)) (if (minusp y) `(- (ash x ,len)) @@ -2680,7 +2680,7 @@ (let* ((y (lvar-value y)) (y-abs (abs y)) (len (1- (integer-length y-abs)))) - (unless (= y-abs (ash 1 len)) + (unless (and (> y-abs 0) (= y-abs (ash 1 len))) (give-up-ir1-transform)) (let ((shift (- len)) (mask (1- y-abs)) @@ -2706,7 +2706,7 @@ (let* ((y (lvar-value y)) (y-abs (abs y)) (len (1- (integer-length y-abs)))) - (unless (= y-abs (ash 1 len)) + (unless (and (> y-abs 0) (= y-abs (ash 1 len))) (give-up-ir1-transform)) (let ((mask (1- y-abs))) (if (minusp y) @@ -2721,7 +2721,7 @@ (let* ((y (lvar-value y)) (y-abs (abs y)) (len (1- (integer-length y-abs)))) - (unless (= y-abs (ash 1 len)) + (unless (and (> y-abs 0) (= y-abs (ash 1 len))) (give-up-ir1-transform)) (let* ((shift (- len)) (mask (1- y-abs))) @@ -2743,7 +2743,7 @@ (let* ((y (lvar-value y)) (y-abs (abs y)) (len (1- (integer-length y-abs)))) - (unless (= y-abs (ash 1 len)) + (unless (and (> y-abs 0) (= y-abs (ash 1 len))) (give-up-ir1-transform)) (let ((mask (1- y-abs))) `(if (minusp x) diff --git a/tests/arith.pure.lisp b/tests/arith.pure.lisp index 8c47082..8d1d12b 100644 --- a/tests/arith.pure.lisp +++ b/tests/arith.pure.lisp @@ -206,3 +206,17 @@ ;;; ASH of a negative bignum by a bignum count would erroneously ;;; return 0 prior to sbcl-0.8.4.4 (assert (= (ash (1- most-negative-fixnum) (1- most-negative-fixnum)) -1)) + +;;; Whoops. Too much optimization in division operators for 0 +;;; divisor. +(macrolet ((frob (name) + `(let ((fn (compile nil '(lambda (x) + (declare (optimize speed) (fixnum x)) + (,name x 0))))) + (assert (raises-error? (funcall fn 1) division-by-zero))))) + (frob mod) + (frob truncate) + (frob rem) + (frob /) + (frob floor) + (frob ceiling)) diff --git a/version.lisp-expr b/version.lisp-expr index 1836c0c..59b49f0 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.13.11" +"0.8.13.12"