summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1996-05-24 13:15:46 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1996-05-24 13:15:46 +0000
commitdc79ea388d62ed18337c82ae67a312e87f324dd3 (patch)
tree5e584ffd5f2881951f003677b3999dc6ca1e5f9a
parentb25e54af7aac98c472144f01ca8f87c738f50070 (diff)
Attention aux debordements arithmetiques...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@837 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--bytecomp/matching.ml4
1 files changed, 3 insertions, 1 deletions
diff --git a/bytecomp/matching.ml b/bytecomp/matching.ml
index 5efd9c97d..b5fb59619 100644
--- a/bytecomp/matching.ml
+++ b/bytecomp/matching.ml
@@ -222,7 +222,9 @@ let make_switch_or_test_sequence arg const_lambda_list int_lambda_list =
List.fold_right (fun (k, l) m -> min k m) int_lambda_list max_int in
let max_key =
List.fold_right (fun (k, l) m -> max k m) int_lambda_list min_int in
- if 4 * List.length int_lambda_list <= 4 + max_key - min_key then
+ (* min_key and max_key can be arbitrarily large, so watch out for
+ overflow in the following comparison *)
+ if List.length int_lambda_list <= 1 + max_key / 4 - min_key / 4 then
(* Sparse matching -- use a sequence of tests
(4 bytecode instructions per test) *)
make_test_sequence (Pintcomp Ceq) arg const_lambda_list