Mauricio Fernandez <[email protected]> wrote:

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

That would not help.

Passing the address of a local variable to an external function
warns the compiler that the variable may change when another
external function is called.  That is necessary and sufficient
to accomodate OCaml's garbage collector.

The problem here is, order of evaluation of function call arguments
is unspecified.

In principle the same bug is present in

  Field(camlvar, 1) = allocating_function(...);

camlvar may be evaluated before the allocating function is called,
and the allocating function may move the object it points to.
I don't know whether the new C sequencing rules change this, but I
wouldn't intentionally write code that depends on the ordering of
this statement.

    --John Carr ([email protected])

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