I submitted a bug report. On Jan 25, 2008 5:47 AM, Loup Vaillant wrote: > 2008/1/25, Oliver Bandel : > > Zitat von Ashish Agarwal : > > > > > I was hoping there would be some follow up discussion on the code > > > below, but > > > haven't seen anything yet. > > [...] > > > > [...] > > It behaves like if s would be defined on top of the > > module, but it is local constructed in the function f. > > Look sstrange... I have the same behaviour here (Debians > > OCaml here is 3.09.2, and I have tried with toplevel, bytecode > > and naticecode). > > Ouch: this is the same as in C: the attempt to modify a statically > defined string makes bad things happen. One should try this on Open > BSD: it may even crash, if the the data segment is protected from > write. Replacing "abc" by String.copy "abc" works around this, though: > > # let f () = let s = String.copy "bla" in let c = s.[0] in s.[0] <- 'c' ; > c ;; > val f : unit -> char = > # f();; > - : char = 'b' > # f();; > - : char = 'b' > > Pure again :-) > > Cheers, > Loup > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >