File 0002-Fix-array-bound-checking-with-negative-indexes-on-AR.patch of Package sbcl
From 5e7d58ea89324d9c9d852fba2fb168b58b215f1a Mon Sep 17 00:00:00 2001
From: Stas Boukarev <stassats@gmail.com>
Date: Sat, 30 Aug 2014 20:51:10 +0400
Subject: [PATCH 2/6] Fix array bound checking with negative indexes on ARM.
Need to use an unsigned comparison, not a signed one, to weed out the
negative numbers.
Patch by Wendall Marvel.
Signed-off-by: Togan Muftuoglu <toganm@opensuse.org>
---
src/compiler/arm/array.lisp | 2 +-
tests/vector.pure.lisp | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/compiler/arm/array.lisp b/src/compiler/arm/array.lisp
index 6d652b4..7fc6622 100644
--- a/src/compiler/arm/array.lisp
+++ b/src/compiler/arm/array.lisp
@@ -73,7 +73,7 @@
(:generator 5
(let ((error (generate-error-code vop 'invalid-array-index-error array bound index)))
(inst cmp index bound)
- (inst b :ge error)
+ (inst b :hs error)
(move result index))))
;;;; Accessors/Setters
diff --git a/tests/vector.pure.lisp b/tests/vector.pure.lisp
index 30c349e..004a3b1 100644
--- a/tests/vector.pure.lisp
+++ b/tests/vector.pure.lisp
@@ -54,3 +54,13 @@
(compile nil `(lambda (a)
(declare ((vector undefined-type) a))
(setf (svref a 0) 10))))
+
+(with-test (:name :svref-negative-index)
+ (let ((vector #(1)))
+ (flet ((test (index)
+ (funcall (compile nil `(lambda (vector index)
+ (svref vector index)))
+ vector index)))
+ (assert-error (test -1))
+ (assert (= (test 0) 1))
+ (assert-error (test 1)))))
--
2.1.0