Skip to content

Commit 0523af4

Browse files
gretay-jspoechsel
authored andcommitted
Fix integer literal that is too big for 32-bit targets (#39)
Fix error "integer literal exceeds the range of representable integers of type nativeint" in the code that runs only on 64-bit targets, but need to compile on 32-bit target.
1 parent 57da870 commit 0523af4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backend/cmm_helpers.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,8 @@ let ctz bi arg dbg =
22182218
let op = Cctz { arg_is_non_zero = true; } in
22192219
if_operation_supported_bi bi op ~f:(fun () ->
22202220
(* Set bit 32 *)
2221-
Cop(op, [Cop(Cor, [arg; Cconst_natint(0x1_0000_0000n, dbg)], dbg)], dbg))
2221+
let mask = Nativeint.shift_left 1n 32 in
2222+
Cop(op, [Cop(Cor, [arg; Cconst_natint(mask, dbg)], dbg)], dbg))
22222223
end else begin
22232224
let op = Cctz { arg_is_non_zero = false; } in
22242225
if_operation_supported_bi bi op ~f:(fun () ->

0 commit comments

Comments
 (0)