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

segmentation fault #3103

Closed
vicuna opened this issue Dec 23, 2001 · 3 comments
Closed

segmentation fault #3103

vicuna opened this issue Dec 23, 2001 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Dec 23, 2001

Original bug ID: 750
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Jan Kroken
Version: ocaml-3.04
OS: linux-2.4.10-ac7 glibc-2.2.2 gcc-3.0.2
Submission from: krs-dhcp323.studby.uio.no (129.240.107.100)

I have the following code as char.ml:

(* char: print a character given it's character number *)

let error format =
Printf.fprintf stderr format
;;

let print_char c =
Printf.printf "hallo\n" ;

Printf.printf "%c\n" (char_of_int c)
;;

if Array.length Sys.argv < 2 then
error "Usage: char value\n"
else
try
let
value = int_of_string Sys.argv.(1)
in
print_char value
with Failure x ->
error "Usage: char value\n"
;;

...and then, on the command line:

$ ocaml char.ml 65
hallo
A

$ ocamlopt -o char char.ml
./char 65
Segmentation fault

@vicuna
Copy link
Author

vicuna commented Dec 23, 2001

Comment author: administrator

Hi,

On Sun, Dec 23, 2001 at 10:24:27PM +0100, jankr@ifi.uio.no wrote:

I have the following code as char.ml:

I think that ocamlopt does not like that you name your files like the
modules of the OCaml standard library. The results are sometimes
surprising: if you name your file "string.ml" or "array.ml", for
example...

--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/

@vicuna
Copy link
Author

vicuna commented Jan 4, 2002

Comment author: administrator

I have the following code as char.ml:
...and then, on the command line:
$ ocamlopt -o char char.ml
./char 65
Segmentation fault

Daniel's explanation is correct: your module Char conflicts with the
module Char from the standard library, which is referenced indirectly
through Printf and then String. Still, ocamlopt should fail with an
error at link-time rather than generate incorrect code! I'm working
on a fix. Thanks for the bug report.

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jan 4, 2002

Comment author: administrator

Fixed 2002-01-04 by XL

@vicuna vicuna closed this as completed Jan 4, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant