+ (unless (eql expected-result
+ (aref (funcall (compile nil `(lambda () ,form))) 3))
+ (error "expected ~S in FUNCALL COMPILE ~S" expected-result form))
+ ;; also do some testing of compilation and verification that
+ ;; errors are thrown appropriately.
+ (unless (eql expected-result
+ (funcall (compile nil `(lambda () (aref ,form 3)))))
+ (error "expected ~S in COMPILED-AREF ~S" expected-result form))
+ (when type
+ (unless (eql expected-result
+ (funcall (compile nil `(lambda () (let ((x ,form))
+ (declare (type ,type x))
+ (aref x 3))))))
+ (error "expected ~S in COMPILED-DECLARED-AREF ~S" expected-result form)))
+ (when (ignore-errors (aref (eval form) 12))
+ (error "error not thrown in EVAL ~S" form))
+ (when (ignore-errors (aref (funcall (compile nil `(lambda () ,form))) 12))
+ (error "error not thrown in FUNCALL COMPILE ~S"))
+ (when (ignore-errors (funcall (compile nil `(lambda () (aref ,form 12)))))
+ (error "error not thrown in COMPILED-AREF ~S" form))
+ (when type
+ (when (ignore-errors (funcall
+ (compile nil `(lambda () (let ((x ,form))
+ (declare (type ,type x))
+ (aref x 12))))))
+ (error "error not thrown in COMPILED-DECLARED-AREF ~S" form))))))
+
+;;; On the SPARC, until sbcl-0.7.7.20, there was a bug in array references
+;;; for small vector elements (spotted by Raymond Toy).
+(assert (= (funcall
+ (lambda (rmdr)
+ (declare (type (simple-array bit (*)) rmdr)
+ (optimize (speed 3) (safety 0)))
+ (aref rmdr 0))
+ #*00000000000000000000000000000001000000000)
+ 0))