[Openmcl-devel] Displaced arrays with invalid array dimension(s).

Mark Cox markcox80 at gmail.com
Sat Aug 1 20:17:59 PDT 2015


G'day,

The function MAKE-ARRAY will return an array with invalid dimensions
in cases where the value of displaced-index-offset plus the total size
of the (invalid) displaced array dimensions is within the range
0 <= x <= (array-total-size target-array).

;; ccl64 --no-init --load issue.lisp
;; Welcome to Clozure Common Lisp Version 1.10-r16339  (DarwinX8664)!
(let ((fn (lambda (displaced-dimensions dimensions offset)
            (let ((array (make-array dimensions)))
              (array-total-size (make-array displaced-dimensions
                                            :displaced-to array
                                            :displaced-index-offset (+ (array-total-size array)
                                                                       offset)))))))
  ;; Should signal an error but prints -1.
  (print (funcall fn -1 10 1))
  ;; Should signal an error but prints -2.
  (print (funcall fn -2 10 1))
  ;; Should signal an error but prints -1.  
  (print (funcall fn -1 '(20 10) 1))
  ;; Should signal an error but prints -10
  (print (funcall fn '(5 -2) 10 1))
  ;; Should signal an error but prints -15
  (print (funcall fn '(5 -3) 10 15)))

Thanks
Mark




More information about the Openmcl-devel mailing list