Created
October 7, 2017 11:38
-
-
Save bcc32/e6f3aa69443ea253a6a0719c2748d2e1 to your computer and use it in GitHub Desktop.
OCaml 4.04.2 Compiler Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type Int = sig | |
val one : int | |
val (+) : int -> int -> int | |
end | |
module Make (Int : Int) = struct | |
(* this assertion must fail in order to make the linker command fail *) | |
let () = assert false | |
(* this assertion doesn't matter *) | |
let () = | |
let falsy () = [1] == [1] in | |
assert (falsy ()) | |
(* both the list and the + are needed to get the linker command to fail *) | |
let two () = [ Int.(one + one) ] | |
end | |
module M = Make(struct | |
let one = 1 | |
let (+) = (+) | |
end) | |
(* This programs fails with a linker error on OCaml version 4.04.2 but not 4.05.0 | |
{[ | |
% jbuilder build @install | |
ocamldep src/main.depends.ocamldep-output | |
ocamlc src/main.{cmi,cmo,cmt} | |
ocamlopt src/main.{cmx,o} | |
ocamlopt src/main.exe (exit 2) | |
(cd _build/default && ~/.opam/4.04.2/bin/ocamlopt.opt -w -40 -g -o src/main.exe src/main.cmx) | |
src/main.o: In function `camlMain__entry': | |
~/.../_build/default/src/main.ml:24: undefined reference to `camlMain__two_1207' | |
collect2: error: ld returned 1 exit status | |
File "caml_startup", line 1: | |
Error: Error during linking | |
]} | |
*) | |
let _ = M.two () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment