Opened 8 years ago

Closed 8 years ago

#1010 closed defect (duplicate)

(setf schar) with fixnum index fails

Reported by: metawilm Owned by:
Priority: normal Milestone:
Component: Compiler Version: trunk
Keywords: Cc:

Description (last modified by gb)

Clozure CL "Version 1.8-r15286M  (LinuxX8632)"

(defun test ()
  (let ((bit-arr (make-array 1000 :element-type 'bit :initial-element 0)))
    ;; Set one bit in the array, for #\A
    (setf (aref bit-arr (char-code #\A)) 1)
    (let ((num-chars 1)
          (char-arr (make-string 1)))
      ;; loop over the bit array, finding the bit, and putting #\A in CHAR-ARR
      (loop for src-char-code fixnum from 0
            with ret-ix fixnum = 0
            when (= (sbit bit-arr src-char-code) 1)
            do (progn (setf (schar char-arr ret-ix) (code-char src-char-code))
                      (incf ret-ix)
                      (if (= ret-ix num-chars)
                        (warn "(ret-ix) ~A != ~A (num-chars)" ret-ix num-chars))))

Running gives:

  Warning: (ret-ix) 1 != 1 (num-chars)
  ; While executing: COMMON-LISP-USER::TEST, in process listener(1).
  > Error: Array index 1000 out of bounds for #<SIMPLE-BIT-VECTOR 1000>

Removing the FIXNUM declaration for RET-IX inside the loop solves it:

  with ret-ix = 0

Change History (2)

comment:1 Changed 8 years ago by gb

  • Description modified (diff)

comment:2 Changed 8 years ago by gb

  • Resolution set to duplicate
  • Status changed from new to closed

The underlying problem was fixed in svn a few months ago. Do:

$ ccl
? (rebuild-ccl :update t :full t) ;or equivalent

See also ticket:962

Note: See TracTickets for help on using tickets.