(CONCATENATE 'string ...) very broken if speed>space
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
(defun foo () (declare (optimize (speed 3) (safety 0))) (concatenate 'string "a" "b"))
(foo) => "b^@"
Likely culprit is http://
The bad transform is
(concatenate 'string "a" "b") ->
(APPLY
(LAMBDA (#:G1 #:G2)
(DECLARE (IGNORABLE #:G1 #:G2))
(DECLARE (OPTIMIZE (INSERT-
(LET* ((.LENGTH. (+ 1 1)) (.POS. 2) (.STRING. (MAKE-STRING .LENGTH. :ELEMENT-TYPE 'CHARACTER)))
(DECLARE (IGNORABLE .POS.))
(DECLARE (TYPE INDEX .LENGTH. .POS.)
(PROGN (SETF (AREF .STRING. (TRULY-THE INDEX 0)) #\a) NIL)
(PROGN (SETF (AREF .STRING. (TRULY-THE INDEX 0)) #\b) NIL)
.STRING.))
Ironically I had mentioned to Christophe in email that the lack of (declare (ignore .POS.)) in the transform had caused us some problems about spurious warnings in the case of only a single string due to our build system consider style-warning to be fatal even in cases that aren't completely broken, e.g.
(concatenate 'string "Hi") ->
(APPLY
(LAMBDA (#:G1)
(DECLARE (IGNORABLE #:G1))
(DECLARE (OPTIMIZE (INSERT-
(LET* ((.LENGTH. (+ 2)) (.POS. 2) (.STRING. (MAKE-STRING .LENGTH. :ELEMENT-TYPE 'CHARACTER)))
(DECLARE (IGNORABLE .POS.))
(DECLARE (TYPE INDEX .LENGTH. .POS.)
(PROGN (SETF (AREF .STRING. (TRULY-THE INDEX 0)) #\H) (SETF (AREF .STRING. (TRULY-THE INDEX 1)) #\i) NIL)
.STRING.))
LVARS)
Changed in sbcl: | |
status: | New → Fix Committed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |