Skip to content

wasm_of_ocaml warns integer-overflow on constants in optint_native / int63_emul #28

Description

@samoht

When trying to use optint with wasm_of_ocaml I got lots of warnings:

$ cat > t.ml <<'EOF'
let () = print_string (Optint.to_string (Optint.of_int 42))
EOF
$ ocamlfind ocamlc -package optint -linkpkg t.ml -o t.byte
$ js_of_ocaml t.byte -o t.js          # silent
$ wasm_of_ocaml t.byte -o t.wasm.js
Warning [integer-overflow]: integer 0x7fffffff (2147483647) truncated to 0xffffffff (-1); the generated code might be incorrect.
Warning [integer-overflow]: integer 0x40000000 (1073741824) truncated to 0xc0000000 (-1073741824); the generated code might be incorrect.
Warning [integer-overflow]: integer 0x40000000 (1073741824) truncated to 0xc0000000 (-1073741824); the generated code might be incorrect.

I think this is warning for dead-code as Immediate64.repr dispatches on Sys.word_size = 64, so a 31-bit runtime only executes optint_emul. So this isn't a big deal but "generated code might be incorrect" spam in my build logs is a bit annoying.

I can try to make a PR to create those constant by converting from an int64 if you are interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions