From 1ee708dfef0cc80906b819509c29c5a7e1ab3ce7 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Mon, 30 Aug 2010 10:44:59 +0000 Subject: [PATCH] 1.0.42.2: correct defknown for data-vector-ref-with-offset * If the offset is positive, the index can be negative and still correct. * Fixes lp#622958 --- NEWS | 5 +++++ src/compiler/fndb.lisp | 2 +- tests/compiler.pure.lisp | 29 +++++++++++++++++++++++++++++ version.lisp-expr | 2 +- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 525a67a..f33c0ab 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,9 @@ ;;;; -*- coding: utf-8; fill-column: 78 -*- +changes relative to sbcl-1.0.42 + * bug fix: bogus type errors from (AREF A (+ POSITIVE-OFFSET N)) under + certain circumstances when N was negative but (+ POSITIVE-OFFSET N) + was non-negative. (lp#622958) + changes in sbcl-1.0.42 relative to sbcl-1.0.41 * build changes ** Cross-compilation host is now specified to make.sh using diff --git a/src/compiler/fndb.lisp b/src/compiler/fndb.lisp index dfb0dcd..5991492 100644 --- a/src/compiler/fndb.lisp +++ b/src/compiler/fndb.lisp @@ -1448,7 +1448,7 @@ (defknown %check-bound (array index fixnum) index (movable foldable flushable)) (defknown data-vector-ref (simple-array index) t (foldable explicit-check always-translatable)) -(defknown data-vector-ref-with-offset (simple-array index fixnum) t +(defknown data-vector-ref-with-offset (simple-array fixnum fixnum) t (foldable explicit-check always-translatable)) (defknown data-vector-set (array index t) t (unsafe explicit-check always-translatable)) diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 5ef755f..c008f31 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -3502,3 +3502,32 @@ (declare (optimize (sb-c::float-accuracy 0))) (* x -1.0d0))) 1)))) + +(with-test (:name :data-vector-ref-with-offset-neg-index) + (let ((fun (compile nil + `(lambda () + (let ((table (make-array 7 + :element-type 'fixnum + :initial-contents '(0 1 2 3 4 5 6)))) + (loop for n from -3 upto 3 + collect (aref table (+ 3 n)))))))) + (assert (equal '(0 1 2 3 4 5 6) (funcall fun))))) + +(with-test (:name :aref-bignum-offset-and-index) + ;; These don't get the data-vector-ref-with-offset vop. + (let ((fun (compile nil + `(lambda () + (let ((table (make-array 7 + :element-type 'fixnum + :initial-contents '(0 1 2 3 4 5 6)))) + (loop for n from most-negative-fixnum upto (+ most-negative-fixnum 6) + collect (aref table (+ #.(1+ most-positive-fixnum) n)))))))) + (assert (equal '(0 1 2 3 4 5 6) (funcall fun)))) + (let ((fun (compile nil + `(lambda () + (let ((table (make-array 7 + :element-type 'fixnum + :initial-contents '(0 1 2 3 4 5 6)))) + (loop for n from (+ most-positive-fixnum 1) upto (+ most-positive-fixnum 7) + collect (aref table (- n (+ most-positive-fixnum 1))))))))) + (assert (equal '(0 1 2 3 4 5 6) (funcall fun))))) diff --git a/version.lisp-expr b/version.lisp-expr index 5f138ab..8091c7a 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".) -"1.0.42.1" +"1.0.42.2" -- 1.7.10.4