Compiler does improper comparison, causing error

Bug #2035146 reported by Paul F. Dietz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

(defun bug232 (c)
  (if (< 0 c)
      (case c ((#\h) 0) (t 3))
      0))

==>

The value
  #\h
is not of type
  REAL
   [Condition of type TYPE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD tid=13351 "repl-thread" RUNNING {10010A00A3}>)

Backtrace:
  0: (SB-KERNEL:TWO-ARG-> 0 #\h)
  1: (SB-VM::GENERIC->)
  2: (SB-C::MAP-EQUALITY-CONSTRAINTS #<SB-C::LVAR 1 {100408A7B3}> #<SB-C::LVAR 2 {100408A6D3}> #S(SB-C::CONSET :VECTOR #*11101010 :MIN 0 :MAX 7) #<FUNCTION (LAMBDA (SB-C::OP SB-C::NOT-P) :IN SB-C::EQ-EQUAL..
  3: (SB-C::EQ-EQUALITY-CONSTRAINT-OPTIMIZER #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME EQ :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :..
  4: (SB-C::TRY-EQUALITY-CONSTRAINT #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME EQ :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLOBAL-FU..
  5: (SB-C::CONSTRAINT-PROPAGATE-IN-BLOCK #<SB-C::CBLOCK 6 :START c3 {1004088C33}> #S(SB-C::CONSET :VECTOR #*11101010 :MIN 0 :MAX 7) T)
  6: (SB-C::FIND-BLOCK-TYPE-CONSTRAINTS #<SB-C::CBLOCK 6 :START c3 {1004088C33}> T)
  7: (SB-C::FIND-AND-PROPAGATE-CONSTRAINTS #<SB-C:COMPONENT :NAME "<unknown>" {10039DF803}>)
  8: (SB-C::CONSTRAINT-PROPAGATE #<SB-C:COMPONENT :NAME "<unknown>" {10039DF803}>)
  9: (SB-C::IR1-OPTIMIZE-PHASE-1 #<SB-C:COMPONENT :NAME "<unknown>" {10039DF803}>)
 10: (SB-C::IR1-PHASES #<SB-C:COMPONENT :NAME "<unknown>" {10039DF803}>)
 11: (SB-C::COMPILE-COMPONENT #<SB-C:COMPONENT :NAME "<unknown>" {10039DF803}>)
 12: (SB-C::%COMPILE (SB-INT:NAMED-LAMBDA BUG232 (C) (BLOCK BUG232 (IF # # 0))) NIL NIL)
 [...]

x86-64, "2.3.8.139-59cbece16"

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Fix Released
Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

The fix uses NUMBERP when it should use REALP. Change the bug to use #C(1 2) instead of #\h and the compiler still errors.

Revision history for this message
Stas Boukarev (stassats) wrote :

Fixed that.

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.