Lisp HUG Maillist Archive

Compiler's type inference bug with (< safety 3) ?

Hi
 
Trying to check out ray tracing example from c.c.l in LispWorks 4.4.6 Personal Edition for Windows, I found that compiler with declarations where safety < 3 counts that any summation result has fixnum type. Example:
 
(defun test (n)
  (declare (fixnum n))
  (let ((some-var (+ (/ (float n 1.0) 2.0) 1.0)))
       (declare (double-float some-var))
       some-var))
 
When you try to compile it with (declaim (optimize (safety 0))) you'll get
;;;*** Warning in TEST: Variable SOME-VAR is declared type FLOAT, but is bound to a value of type FIXNUM
 
Same without (+ expr 1.0) compiles without warnings.
 
Is it bug ?
 
Regards
Lisper
 
 
 
 
 
 

Re: Compiler's type inference bug with (< safety 3) ?

(defun test (n)
  (declare (fixnum n) (optimize (safety 0) (fixnum-safety 3)))
  (let ((some-var (+ (/ (float n 1.0) 2.0) 1.0)))
       (declare (double-float some-var))
       some-var))

This compiles fine.

(defun test (n)
  (declare (fixnum n) (optimize (safety 0) (fixnum-safety 2)))
  (let ((some-var (+ (/ (float n 1.0) 2.0) 1.0)))
       (declare (double-float some-var))
       some-var))

This causes your error, see

http://www.lispworks.com/documentation/lw445/LWUG/html/lwuser-89.htm#pgfId-886019

This behaviour is documented.  Return fixnum-safety to 3 for the 
compilation.  This is problem with
declaim, its too global.

Wade

> Hi
>  
> Trying to check out ray tracing example from c.c.l in LispWorks 4.4.6 
> Personal Edition for Windows, I found that compiler with declarations 
> where safety < 3 counts that any summation result has fixnum type. 
> Example:
>  
> (defun test (n)
>   (declare (fixnum n))
>   (let ((some-var (+ (/ (float n 1.0) 2.0) 1.0)))
>        (declare (double-float some-var))
>        some-var))
>  
> When you try to compile it with (declaim (optimize (safety 0))) you'll get
> ;;;*** Warning in TEST: Variable SOME-VAR is declared type FLOAT, but 
> is bound to a value of type FIXNUM
>  
> Same without (+ expr 1.0) compiles without warnings.
>  
> Is it bug ?
>  
> Regards
> Lisper
>  
>  
>  
>  
>  
>  



Updated at: 2020-12-10 08:49 UTC