Steel Bank Common Lisp

FLOATING-POINT-INVALID-OPERATION compiling NaNs

Reported by 3b on 2009-11-22
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

Bug Description

compiling
(defun foo () (sb-kernel:make-double-float -1 0))
on 1.0.32.37/linux/x8664, and 1.0.21/linux/x86
causes

debugger invoked on a FLOATING-POINT-INVALID-OPERATION in thread #<THREAD "initial thread" RUNNING {1002A76011}>:
  arithmetic error FLOATING-POINT-INVALID-OPERATION signalled

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-KERNEL:TWO-ARG-> #<DOUBLE-FLOAT quiet NaN> #<DOUBLE-FLOAT quiet NaN>)
0] 0

pkhuong suggests make-numeric-type as the problem

Paul Khuong (pvk) wrote :

There's no way to represent NaNs in numeric types. This results in other bugs, e.g.

(defun foo (x)
  (declare (double-float x)) ; weirdly enough, the constraints are too simple-minded to be a problem otherwise
  (cond ((< x 0))
        ((< -1 x))
        (t 42))) ; the last clause is constraint-propagated away

Another instance of the FP correctness metabug. I think we want to extend float types to also indicate whether they contain SNaNs, QNaNs or infinities (and maybe signed zeros or denorms). I'm not sure how to expose that to the user.

tags: added: floating-point

 status confirmed
 importance low

Traps are off by default on darwin, so this issue doesn't appear there. (Type-system limitation apply of course.)

I think Nathan has the right idea:

[17:44] <froydnj> make MAKE-DOUBLE-FLOAT should not be trivially-foldable (via DEFKNOWN) and have a special DEFTRANSFORM instead

Changed in sbcl:
importance: Undecided → Low
status: New → Confirmed
Paul Khuong (pvk) wrote :

commit 9e37bfc1ef0532a16a9ac8b1e48123ee19347f80
Author: Paul Khuong <email address hidden>
Date: Sat Jun 11 01:41:27 2011 -0400

   Avoid constant folding NaNs from MAKE-{SINGLE,DOUBLE}-FLOAT

   Perform it in a specialised transform that checks for NaNs, and
   add VOPs for constant arguments to avoid any slowdown.

   Fixes lp#486812.

Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers