diff options
author | Andy Wingo <wingo@pobox.com> | 2019-11-27 16:00:43 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-11-27 16:03:59 +0100 |
commit | 8304b15807debfb1aba6ef6510e42d6174a92215 (patch) | |
tree | f450961c2cec165c22b845251d29a533afd3c0a2 /module/srfi | |
parent | 7190905109028a43b7471785e05e9a07098e9127 (diff) | |
download | guile-8304b15807debfb1aba6ef6510e42d6174a92215.tar.gz |
Fix range inference on division in unreachable code
* module/language/cps/types.scm (div-result-range): It is possible for a
max value to be less than a minimum. In this bug from zig:
(define (benchmark x)
(let loop ((count 0)
(sum 0))
(if (= count 10)
(exact->inexact (/ sum 10)))
(loop (+ count 1) x)))
Here the first iteration gets peeled, and thus the first "if" can't be
true, because "count" is zero. However on the true branch of the if,
range inference produces bogus ranges -- notably, the variable bound
to 10 is inferred to have a min of 10 and a max of 0. This is fine,
because it's unreachable; but that then infects the division, because
the same variable bound to 10 is used there, resulting in division by
zero.
Diffstat (limited to 'module/srfi')
0 files changed, 0 insertions, 0 deletions