Skip to content

Commit 4cf14ca

Browse files
committed
Compiler: fix 32bit build
1 parent 57126b5 commit 4cf14ca

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

compiler/lib/targetint.ml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ let max_int_ (Offset offset) = Int32.shift_right Int32.max_int offset
3131

3232
let min_int_ (Offset offset) = Int32.shift_right Int32.min_int offset
3333

34-
let min_int_i offset = Int32.to_int (min_int_ offset)
35-
36-
let max_int_i offset = Int32.to_int (max_int_ offset)
37-
3834
let min_int () =
3935
let offset = offset () in
4036
min_int_ offset
@@ -50,7 +46,7 @@ let to_float x = Int32.to_float x
5046
let to_int32 x = x
5147

5248
let to_int_exn x =
53-
if Sys.int_size <= 32 || Int32.of_int Int.min_int <= x || x <= Int32.of_int Int.max_int
49+
if Sys.int_size >= 32 || Int32.of_int Int.min_int <= x || x <= Int32.of_int Int.max_int
5450
then Int32.to_int x
5551
else failwith "to_int_exn"
5652

@@ -102,9 +98,10 @@ let is_zero x = equal x 0l
10298

10399
let of_int_exn (x : int) =
104100
let offset = offset () in
105-
if min_int_i offset <= x && x <= max_int_i offset
101+
if Sys.int_size <= 32
102+
|| (Int32.to_int (min_int_ offset) <= x && x <= Int32.to_int (max_int_ offset))
106103
then Int32.of_int x
107-
else failwith "of_int_exn"
104+
else failwith (Printf.sprintf "of_int_exn(%d)" x)
108105

109106
let of_int32_exn (x : int32) =
110107
let offset = offset () in

0 commit comments

Comments
 (0)