mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-14 05:12:38 -08:00
The optimizer for COERCE may enter an infinite loop with integer ranges
This commit is contained in:
parent
bc6ae2146f
commit
0bceff2ff6
1 changed files with 9 additions and 5 deletions
|
|
@ -188,8 +188,9 @@
|
|||
;;; lisp form. We use a LET form to avoid evaluating twice the same
|
||||
;;; form.
|
||||
;;;
|
||||
(defvar +coercion-table+
|
||||
'((float . (float x))
|
||||
(defparameter +coercion-table+
|
||||
'((integer . (check-type x 'integer))
|
||||
(float . (float x))
|
||||
(short-float . (float x 0.0s0))
|
||||
(single-float . (float x 0.0f0))
|
||||
(double-float . (float x 0.0d0))
|
||||
|
|
@ -284,16 +285,17 @@
|
|||
;;
|
||||
;; (INTEGER * *), etc We have to signal an error if the type
|
||||
;; does not match. However, if safety settings are low, we
|
||||
;; skip this test.
|
||||
;; skip the interval test.
|
||||
((member first '(INTEGER RATIONAL FLOAT REAL SINGLE-FLOAT
|
||||
DOUBLE-FLOAT #+long-float LONG-FLOAT
|
||||
#+short-float SHORT-FLOAT))
|
||||
(let ((unchecked (expand-coerce form value `',first env)))
|
||||
(if (< safety 1)
|
||||
default
|
||||
unchecked
|
||||
`(let ((x ,unchecked))
|
||||
(declare (,first x))
|
||||
(check-type x ',type "coerced value")
|
||||
(unless (and ,@(expand-in-interval-p 'x (rest type)))
|
||||
(si::do-check-type x ',type nil "coerced value"))
|
||||
x))))
|
||||
;;
|
||||
;; We did not find a suitable expansion.
|
||||
|
|
@ -303,3 +305,5 @@
|
|||
|
||||
(define-compiler-macro coerce (&whole form value type &environment env)
|
||||
(expand-coerce form value type env))
|
||||
|
||||
(trace c::expand-coerce)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue