Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: exception End_of_file when using -o file.cmo #5611

Closed
vicuna opened this issue May 10, 2012 · 3 comments
Closed

Fatal error: exception End_of_file when using -o file.cmo #5611

vicuna opened this issue May 10, 2012 · 3 comments
Labels
Milestone

Comments

@vicuna
Copy link

@vicuna vicuna commented May 10, 2012

Original bug ID: 5611
Reporter: @zoggy
Assigned to: meyer
Status: closed (set by @xavierleroy on 2015-12-11T18:08:06Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.00.0+dev
Target version: 4.01.0+dev
Fixed in version: 4.01.0+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

Giving a .cmo file to -o option of ocamlc without -c ends with a fatal error.

Steps to reproduce

ocamlc -v

The OCaml compiler, version 4.00.0+dev17_2012-05-02
Standard library directory: /opt/ocaml-4/lib/ocaml

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

@vicuna
Copy link
Author

@vicuna vicuna commented Jul 9, 2012

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...

@vicuna
Copy link
Author

@vicuna vicuna commented Sep 1, 2012

Comment author: meyer

Improved error message to avoid clashes: r12901

@vicuna
Copy link
Author

@vicuna vicuna commented Sep 21, 2012

Comment author: @damiendoligez

r 12901 (in trunk) fixes this.

@vicuna vicuna closed this Dec 11, 2015
@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant