From 54caaf4373cfb03a8a76b3531079ef87ce55781c Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Fri, 21 Oct 2005 13:11:59 +0000
Subject: [PATCH] CLHS 2.3.1.1 says if " token with the syntax of a number
 cannot be converted to an internal number, an error of type reader-error is
 signaled."

So, disable underflow traps, convert the number.  If the resulting
float is zero, but the number was not, signal a reader-error.
---
 code/reader.lisp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/code/reader.lisp b/code/reader.lisp
index 82ae7f07e..7d6279cbb 100644
--- a/code/reader.lisp
+++ b/code/reader.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/reader.lisp,v 1.56 2005/05/06 20:36:31 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/reader.lisp,v 1.57 2005/10/21 13:11:59 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1538,8 +1538,17 @@ the end of the stream."
 	  (t (error "Internal error in floating point reader.")))))
 
 (defun make-float-aux (number divisor float-format stream)
-  (handler-case 
-      (coerce (/ number divisor) float-format)
+  (handler-case
+      (with-float-traps-masked (:underflow)
+	(let ((result (coerce (/ number divisor) float-format)))
+	  (when (and (zerop result) (not (zerop number)))
+	    ;; With underflow traps disabled, reading any number
+	    ;; smaller than least-positive-foo-float will return zero.
+	    ;; But we really want to indicate that we can't read it.
+	    ;; So if we converted the number to zero, but the number
+	    ;; wasn't actually zero, throw an error.
+	    (error "Underflow"))
+	  result))
     (error ()
 	   (%reader-error stream "Floating-point number not representable"))))
 
-- 
GitLab