Hi Jan, Jan Nieuwenhuizen writes: > ;; foo.scm > (let* ((set-mask (pk 'set-mask (ash 3 3))) > (clear-mask (pk 'clear-mask (logxor set-mask -1)))) > (pk 'expected (logxor 24 -1)) > (display clear-mask) > (newline) > clear-mask) > > > behaves as I expect when compilation is turned off [...] > but when (auto)compiled, look: [...] > ;;; (set-mask 24) > > ;;; (clear-mask -1) > > ;;; (expected -25) > -1 Indeed, thanks for the report. Guile 2.2's type inference pass contained several bugs in the range analysis of bitwise logical operators. I've attached below a preliminary (not fully tested) patch that hopefully fixes these problems, and also makes some improvements. > Is this a bug, can you suggest a workaround? The specific workaround here would be to use (lognot x) instead of (logxor x -1), which is a bit nicer anyway. They are equivalent. Another equivalent formulation is (- -1 x). Mark