Adjusting a non adjustable array clobbers it

Bug #886418 reported by Ilya Perminov
6
This bug affects 1 person
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

Revision history for this message
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
Revision history for this message
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)
Changed in sbcl:
status: Invalid → Confirmed
Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.