0.9.1.40:
[sbcl.git] / tests / compiler.impure-cload.lisp
index 9a2d2f6..c82bef3 100644 (file)
            (foo-b (z) (foo-a z)))
     (declare (inline foo-a))
     (foo-a x)))
+
+;;; broken inference of an upper bound of an iteration variable,
+;;; reported by Rajat Datta.
+(defun isieve (num)
+  (let ((vec (make-array num :initial-element 0))
+        (acc 0))
+    (do ((i 2 (+ i 1)))
+        ((>= i num) 'done)
+      (when (= (svref vec i) 0)
+        (do ((j (* i i) (+ j i)))
+            ((>= j num) 'done)
+          (setf (svref vec j) 1))
+        (incf acc)))
+    acc))
+
+(assert (= (isieve 46349) 4792))
+
+;;; COERCE should not be constant-folded (reported by Nikodemus
+;;; Siivola)
+(let ((f (gensym)))
+  (setf (fdefinition f) (lambda (x) x))
+  (let ((g (compile nil `(lambda () (coerce ',f 'function)))))
+    (setf (fdefinition f) (lambda (x) (1+ x)))
+    (assert (eq (funcall g) (fdefinition f)))))
+
+(let ((x (coerce '(1 11) 'vector)))
+  (incf (aref x 0))
+  (assert (equalp x #(2 11))))
+
 \f
 (sb-ext:quit :unix-status 104)