Fatal error: exception End_of_file when using -o file.cmo #5611
Original bug ID: 5611
Giving a .cmo file to -o option of ocamlc without -c ends with a fatal error.
Steps to reproduce
The OCaml compiler, version 4.00.0+dev17_2012-05-02
cat > t.ml
let x = 1;;
ocamlc -o t.cmo t.ml
Fatal error: exception End_of_file
But the following works:
ocamlc -c -o t.cmo t.ml
ocamlc -o t.x t.ml
The text was updated successfully, but these errors were encountered:
Comment author: @damiendoligez
This works too:
ocamlc -o x.cmo t.ml
My guess: when you say "ocamlc -o t.cmo t.ml", the compiler first compiles t.ml to t.cmo, then tries to link the t.cmo object file to produce an executable named t.cmo. At some point, it opens t.cmo for writing (thus erasing it), then tries to copy data from t.cmo to t.cmo, which fails.
I think we need a better error message. In the meantime, the workaround is obvious: don't do that.
Also, I have no idea how it could work in 3.12.1...