Skip to content
Snippets Groups Projects
Commit a608fe30 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

Merge branch 'fix/integer/gmp-overflow' into 'master'

Handling GMP overflow in `power_int_positive_int`

Closes #414

See merge request frama-c/frama-c!4464
parents 6bbee0c8 398afda2
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,9 @@ let two_power n = ...@@ -38,7 +38,9 @@ let two_power n =
else else
two_power_of_int k two_power_of_int k
let power_int_positive_int = Big_int_Z.power_int_positive_int let power_int_positive_int_opt n e =
try Some (Big_int_Z.power_int_positive_int n e)
with Invalid_argument _ -> None
let popcount = Z.popcount let popcount = Z.popcount
......
...@@ -203,7 +203,7 @@ val two_power : t -> t ...@@ -203,7 +203,7 @@ val two_power : t -> t
val two_power_of_int : int -> t val two_power_of_int : int -> t
(** Computes [2^n] *) (** Computes [2^n] *)
val power_int_positive_int: int -> int -> t val power_int_positive_int_opt : int -> int -> t option
(** Exponentiation *) (** Exponentiation *)
val extract_bits : start:t -> stop:t -> t -> t val extract_bits : start:t -> stop:t -> t -> t
......
This diff is collapsed.
...@@ -767,10 +767,8 @@ module Make ...@@ -767,10 +767,8 @@ module Make
subvalues that are all evaluated. Limits the number of splits to subvalues that are all evaluated. Limits the number of splits to
keep the number of evaluations linear on [nb]. *) keep the number of evaluations linear on [nb]. *)
let subdivnb = let subdivnb =
if nb > 3 if 3 < nb && nb < 63
then then (subdivnb * nb) / (1 lsl (nb - 1))
let pow = Integer.power_int_positive_int in
(subdivnb * nb) / (Integer.to_int_exn (pow 2 (nb - 1)))
else subdivnb else subdivnb
in in
Self.result ~current:true ~once:true ~dkey Self.result ~current:true ~once:true ~dkey
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment