On fastpath, 32/64 bit zeros must be allocated each time (Hans Ole Rafaelsen).
[ocaml-bitstring.git] / pa_bitstring.ml
index 71eabed..0c09356 100644 (file)
@@ -666,9 +666,17 @@ let output_bitmatch _loc bs cases =
                  | 16 ->
                      <:expr< Bitstring.$lid:name$ $lid:data$ o >>
                  | 32 ->
-                     <:expr< Bitstring.$lid:name$ $lid:data$ o 0l >>
+                     <:expr<
+                       (* must allocate a new zero each time *)
+                       let zero = Int32.of_int 0 in
+                       Bitstring.$lid:name$ $lid:data$ o zero
+                     >>
                  | 64 ->
-                     <:expr< Bitstring.$lid:name$ $lid:data$ o 0L >>
+                     <:expr<
+                       (* must allocate a new zero each time *)
+                       let zero = Int64.of_int 0 in
+                       Bitstring.$lid:name$ $lid:data$ o zero
+                     >>
                  | _ -> assert false in
                <:expr<
                  (* Starting offset within the string. *)