Skip to content

ocamlopt: operand size mismatch for `imul' on 4.12.0 #10626

@actionshrimp

Description

@actionshrimp

I'm seeing the error below from ocamlopt.

This is approaching the smallest repro I could find after experimenting with it a bit, removing certain functions inside the module stops the issue from appearing, as does moving everything to top level (outside of a module functor).

The same file runs through ocamlopt on 4.08.1 without issue.

$ uname -m
x86_64

$ opam exec -- ocamlopt --version
4.12.0

$ cat int64_test.ml
module Datetime = struct
  module Conv (M : sig
    val xs_in_a_second : int64

    val picos_in_an_x : int64
  end) =
  struct
    open Int64

    let second = M.xs_in_a_second

    let minute = mul (of_int 60) second

    let hour = mul (of_int 60) minute

    let day = mul (of_int 24) hour

    let to_picos micros = mul micros M.picos_in_an_x

    let of_picos picos = div picos M.picos_in_an_x

    let to_days micros = div micros day

    let of_days days = mul days day

    let f x =
      let y = to_days x in
      y


    let of_days_picos (days, picos) = add (of_days days) (of_picos picos)
  end
end

$ opam exec -- ocamlopt int64_test.ml
/tmp/camlasm6c2cb6.s: Assembler messages:
/tmp/camlasm6c2cb6.s:51: Error: operand size mismatch for `imul'
File "int64_test.ml", line 1:
Error: Assembler error, input left in file /tmp/camlasm6c2cb6.s

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions