Adjusting a non adjustable array clobbers it
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
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
Changed in sbcl: | |
status: | Invalid → Confirmed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
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".