Off-by-one (or, type mismatch) error in LOGTEST of fixnums

Bug #1939897 reported by Sean Maher
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Douglas Katzman

Bug Description

In the following:

(defstruct bitsy
  (fix 0 :type fixnum))

(defun s62 (x) (logtest (ash 1 62) (bitsy-fix (truly-the bitsy x))))

(s62 (make-bitsy :fix (ash 1 61)))
=> T

The last expression returns T when it should return NIL.

SBCL's version is "SBCL 2.1.5.173.HEAD.1-e36ecc2b4", but I'm not sure why it's tagged 2.1.5, it's one of the most recent commits.

Uname -a: Linux rooty 5.12.14_1 #1 SMP 1625102948 x86_64 GNU/Linux

Features:
(:SWANK :QUICKLISP :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-UNIX
 :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :X86-64 :GENCGC :64-BIT :ANSI-CL
 :COMMON-LISP :ELF :IEEE-FLOATING-POINT :LINUX :LITTLE-ENDIAN
 :PACKAGE-LOCAL-NICKNAMES :SB-CORE-COMPRESSION :SB-DEVEL :SB-LDB
 :SB-PACKAGE-LOCKS :SB-THREAD :SB-UNICODE :SBCL :UNIX)

Revision history for this message
Douglas Katzman (dougk) wrote :

The vop combining optimizer got confused which happens only when mixing a (signed-byte 64) operand and a fixnum, and (ash 1 62) exceeds a fixnum, so it has to be (signed-byte 64).

Changed in sbcl:
assignee: nobody → Douglas Katzman (dougk)
Douglas Katzman (dougk)
Changed in sbcl:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.