Adjusting a non adjustable array clobbers it

Bug #886418 reported by Ilya Perminov on 2011-11-05
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

When ADJUST-ARRAY is asked to reduce the size of a non adjustable array, it should create a new independent array and copy the contents of the original array into it. Instead it rearranges the contents of the original array to match the new dimensions and returns a new array that shares the storage with the original one. The standard says "If the array returned by adjust-array is distinct from ARRAY, then the argument ARRAY is unchanged."

Test case:
(let* ((a (make-array '(3 3) :initial-contents '((0 1 2) (3 4 5) (6 7 8))))
                (b (adjust-array a '(2 2))))
           (setf (aref a 0 0) 11)
           (values a b (eq a b))) ; => #2A((11 1 3) (4 4 5) (6 7 8)) #2A((11 1) (3 4)) NIL

Paul Khuong (pvk) wrote :

From ADJUST-ARRAY: "The result is an array of the same type and rank as array, that is either the modified array, or a newly created array"

From the Glossary: "distinct adj. not identical." and "identical adj. the same under eq."

In this case, "the array returned by adjust-array is" *not* "distinct from array".

Changed in sbcl:
status: New → Invalid
Ilya Perminov (iperminov) wrote :

Sorry, my description was not clear enough. In my test case the array returned from ADJUST-ARRAY is NOT the same under EQ as the original one.

Paul Khuong (pvk) on 2011-11-05
Changed in sbcl:
status: Invalid → Confirmed
Stas Boukarev (stassats) wrote :

In e15edc206310d6d8e7a4a19f2557bc1925401ad6

Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers