Lisp HUG Maillist Archive

bug in 5.1 (and 5.1.1): compiled modulo arithmetic.


Calling mod with a negative divisor constant in a function definition 
fails to return the correct value when running compiled under LispWorks 
5.1 and 5.1.1. (Mac OS X 32 bit)    It runs ok when running interpreted. 

This simple routine illustrates the problem. Note that it also works 
fine under LispWorks 5.0 (and 5.0.1, etc.)

(defun neg-mod (x)
    (mod x -4))

(neg-mod 5) => -3 ;; correct value returned when running interpreted
(neg-mod 5) => 1   ;; incorrect value returned when running compiled.



If, instead of putting -4 directly into the function, it is passed in as 
a separate argument, then the calculation runs correctly.


Hope this helps,

Chris


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