Trac 64: Type derivation/compiler bug
From Trac 64.
Compiling the following function causes a compiler bug:
(defun bug (n input output desired gain smooth)
(declare (type (complex double-float) desired gain)
(type double-float smooth)
(type (simple-array single-float (*)) input)
(type (simple-array (complex single-float) (*)) output)
(fixnum n)
(optimize (speed 3) (safety 0)))
(dotimes (k n)
(declare (fixnum k))
(setf gain (+ gain (* (- desired gain) smooth)))
(let ((p (* gain (aref input k))))
(setf (aref output k) p)))
(+ 0 gain))
The message is caused by (* gain (aref input k))
:
; (* GAIN (AREF INPUT K))
; ==>
; (* C::X (COERCE C::Y 'DOUBLE-FLOAT))
; Warning: Result is a (COMPLEX
; DOUBLE-FLOAT), not a (VALUES &OPTIONAL (COMPLEX SINGLE-FLOAT) &REST T).
;
; Note: Forced to do GENERIC-* (cost 30).
; Unable to do inline complex float arithmetic (cost 4) because:
; This shouldn't happen! Bug?
; Result types invalid.
;