summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--otherlibs/num/nat.ml4
2 files changed, 4 insertions, 1 deletions
diff --git a/Changes b/Changes
index e02afa75a..f2d6c8c9c 100644
--- a/Changes
+++ b/Changes
@@ -241,6 +241,7 @@ Bug fixes:
- PR#6123: Assert failure when self escapes its class
- PR#6158: Fatal error using GADTs
- PR#6163: Assert_failure using polymorphic variants in GADTs
+- PR#6164: segmentation fault on Num.power_num of 0/1
Feature wishes:
- PR#5181: Merge common floating point constants in ocamlopt
diff --git a/otherlibs/num/nat.ml b/otherlibs/num/nat.ml
index 2c7e7a91c..981f83539 100644
--- a/otherlibs/num/nat.ml
+++ b/otherlibs/num/nat.ml
@@ -355,8 +355,10 @@ let int_to_string int s pos_ref base times =
(* XL: suppression de adjust_string *)
let power_base_int base i =
- if i = 0 then
+ if i = 0 || base = 1 then
nat_of_int 1
+ else if base = 0 then
+ nat_of_int 0
else if i < 0 then
invalid_arg "power_base_int"
else begin