Version française
Home     About     Download     Resources     Contact us    
Browse thread
Line number for index out of bounds
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Line number for index out of bounds
On Mon, Mar 06, 2006 at 08:08:02PM +0100, Andries Hekstra wrote:
> If I would use this week of the trip to try this suggestion you made, how 
> will the stack trace give me the line number?

I forgot to say that not only must you run your program in bytecode,
but you must compile your program with the '-g' option.

It will do something like this:

$ cat test.ml 
let a = Array.make 10 0
let f () = a.(11)
let g = f
let h = g
let main = h ()

$ ocamlc -g test.ml -o test

$ ./test 
Fatal error: exception Invalid_argument("index out of bounds")

$ OCAMLRUNPARAM=b ./test
Fatal error: exception Invalid_argument("index out of bounds")
Raised by primitive operation at unknown location
Called from file "test.ml", line 5, character 15

As you can see, often the stack backtraces aren't very accurate either :-(

You might want to look at Marcus Mottl's patch instead ...

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com