Skip to content

Commit eddfdc1

Browse files
authored
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 abc0a8c commit eddfdc1

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
@@ -2207,7 +2207,8 @@ let ctz bi arg dbg =
22072207
let op = Cctz { arg_is_non_zero = true; } in
22082208
if_operation_supported_bi bi op ~f:(fun () ->
22092209
(* Set bit 32 *)
2210-
Cop(op, [Cop(Cor, [arg; Cconst_natint(0x1_0000_0000n, dbg)], dbg)], dbg))
2210+
let mask = Nativeint.shift_left 1n 32 in
2211+
Cop(op, [Cop(Cor, [arg; Cconst_natint(mask, dbg)], dbg)], dbg))
22112212
end else begin
22122213
let op = Cctz { arg_is_non_zero = false; } in
22132214
if_operation_supported_bi bi op ~f:(fun () ->

0 commit comments

Comments
 (0)