Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Strange performances
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-01-18 (17:05)
From: Olivier Andrieu <oandrieu@n...>
Subject: Re: [Caml-list] Strange performances

On Jan 18, 2008 5:55 PM, Benjamin Canou <> wrote:
> This code works perfectly :
> let list_of_string s =
>   let rec list_of_string s i =
>     try let e = s.[i] in e :: list_of_string s (succ i)
>     with Invalid_argument "index out of bounds" -> []
>   in list_of_string s 0

well, until you compile with the -unsafe flag ....

> Jacques, if I remember well, the ocaml runtime is not able to detect
> stack overflows in native code on all platforms, that's why you get a
> segfault instead of a Stack overflow exception.

indeed, stack overflow of native code is not detected on all platforms.
Even on platforms where it is supported, you won't get an exception if
the overflow occurs in a function inside the C runtime.