ccl
ccl copied to clipboard
error with nested typed SETF
Minimal reproducible example:
(defun GETREFV_U32 (n x)
(make-array n :initial-element x
:element-type '(unsigned-byte 32)))
(defmacro SETELT_U32 (v i s)
`(setf (aref (the (simple-array (unsigned-byte 32) (*)) ,v) ,i)
,s))
(DEFUN t1 (M J)
(BLOCK SEQ
(SETELT_U32 M J (SETELT_U32 M J 1))
(RETURN-FROM SEQ NIL))
)
When running t1 with simple arguments:
? (t1 (GETREFV_U32 5 2) 1)
> Error: Error reporting error
If I redefine error handler, I can get:
The value #<BOGUS object @ #xFFFFFFF800000007> is not of the expected type (UNSIGNED-BYTE 32).
The value xFFFFFFF800000007 shows in (disassemble #'t1).
If the type declaration is removed, then there's no error. There's also no error if the nested SETELT_U32 is rewrite as 2 consecutive SETELT_U32 with the help of a temp variable.
So I guess this bug happens somewhere in the compiler's optimizer.