From: Christophe Rhodes Date: Thu, 26 Jun 2003 09:54:54 +0000 (+0000) Subject: 0.8.1.6: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=27b8aecceb0faecf64fcc8b90392373461b01c30;p=sbcl.git 0.8.1.6: Fix off-by-one error in %CHECK-BOUNDS transform for known array dimensions --- diff --git a/BUGS b/BUGS index ca347e1..7d606d7 100644 --- a/BUGS +++ b/BUGS @@ -1011,7 +1011,7 @@ WORKAROUND: array types, there's no good way to tell it you're doing it intentionally so that it should shut up and just compile the code. - Another poblem is confusing error message "asserted type ARRAY + Another problem is confusing error message "asserted type ARRAY conflicts with derived type (VALUES SIMPLE-VECTOR &OPTIONAL)" during compiling (LAMBDA (V) (VALUES (SVREF V 0) (VECTOR-POP V))). @@ -1024,6 +1024,13 @@ WORKAROUND: 258: (fixed in 0.8.1.3) +259: + (compile nil '(lambda () (aref (make-array 0) 0))) compiles without + warning. Analogous cases with the index and length being equal and + greater than 0 are warned for; the problem here seems to be that the + type required for an array reference of this type is (INTEGER 0 (0)) + which is canonicalized to NIL. + DEFUNCT CATEGORIES OF BUGS IR1-#: These labels were used for bugs related to the old IR1 interpreter. diff --git a/NEWS b/NEWS index 240bc66..b479b76 100644 --- a/NEWS +++ b/NEWS @@ -1885,6 +1885,9 @@ changes in sbcl-0.8.1 relative to sbcl-0.8.0: * fixed bugs 3cd: structure slot readers perform type check if the slot can have an invalid value (i.e. it is either not initialized or can be written with a less specific slot writer). + * bug fix: the compiler now traps array references to elements off + the end of an array; previously, the bounds checking in some + circumstances could go off-by-one. planned incompatible changes in 0.8.x: * (not done yet, but planned:) When the profiling interface settles diff --git a/src/compiler/array-tran.lisp b/src/compiler/array-tran.lisp index 7afe2cd..d0f9baf 100644 --- a/src/compiler/array-tran.lisp +++ b/src/compiler/array-tran.lisp @@ -565,7 +565,7 @@ (give-up-ir1-transform)) (t (let ((dim (continuation-value dimension))) - `(the (integer 0 ,dim) index))))) + `(the (integer 0 (,dim)) index))))) ;;;; WITH-ARRAY-DATA diff --git a/tests/array.pure.lisp b/tests/array.pure.lisp index 50f9987..21b5b69 100644 --- a/tests/array.pure.lisp +++ b/tests/array.pure.lisp @@ -116,3 +116,14 @@ (assert (eq (array-element-type a) 'nil))) (assert (eq (upgraded-array-element-type 'nil) 'nil)) + +(multiple-value-bind (fun warn fail) + (compile nil '(lambda () (aref (make-array 0) 0))) + #+nil (assert fail) ; doesn't work, (maybe because ASSERTED-TYPE is NIL?) + (assert (raises-error? (funcall fun) type-error))) + +(multiple-value-bind (fun warn fail) + (compile nil '(lambda () (aref (make-array 1) 1))) + (assert fail) + (assert (raises-error? (funcall fun) type-error))) + diff --git a/version.lisp-expr b/version.lisp-expr index cee4763..455ce52 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.1.5" +"0.8.1.6"