Found bug in truncating floats to integers ???
Hi
I've found how to simply reproduce that case when result
is float despite of TRUNCATE call.
(defun test-bug (value fn)
(let ((pseudo-fixnum 5))
(declare (fixnum pseudo-fixnum))
(setf pseudo-fixnum (+ value pseudo-fixnum))
(funcall fn (truncate pseudo-fixnum))))
(let ((pseudo-fixnum 5))
(declare (fixnum pseudo-fixnum))
(setf pseudo-fixnum (+ value pseudo-fixnum))
(funcall fn (truncate pseudo-fixnum))))
(defun bug-raise (fixnum-value)
(declare (fixnum fixnum-value))
(format t "Value = ~D~%" fixnum-value))
(declare (fixnum fixnum-value))
(format t "Value = ~D~%" fixnum-value))
(test-bug 5.0 #'bug-raise)
You should see in output window that "Value = 10.0"
instead of expected "Value = 10" (because it should be converted to integer by
TRUNCATE function).
I know that it is wrong using of declarations, but this
makes possible to pass
float instead of integer even if argument variable is
declared fixnum and truncated before passing to another function, and root
of this error is comparatively hard to detect.
Regards
Lisper