On Tue, Aug 16, 2011 at 01:21:02PM +0400, Dmitry Bely wrote:
> On Tue, Aug 16, 2011 at 12:57 PM, Christophe TROESTLER
> <[email protected]> wrote:
> > On Tue, 16 Aug 2011 11:37:03 +0400, Dmitry Bely wrote:
> >> In the line
> >>
> >>         list = wrp_ml_cons(caml_copy_string(*s), list); /* bug! */
> >>
> 
> Let me explain again. Before wrp_ml_cons() is called, C compiler
> 
> 1. Pushes a _copy_ of list value onto the stack.
> 2. Calls caml_copy_string(*s) and pushes its result onto the stack also.
> 3. Calls wrp_ml_cons().
> 
> After (2) the second parameter of wrp_ml_cons() becomes invalid: it is
> a _copy_ of list, not registered as a local root.

This has been in my mind for a while: why don't CAMLparamX declare the local
variables as volatile?

-- 
Mauricio Fernandez  -   http://eigenclass.org

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to