Browse thread
Concatenation of static strings?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Ashish Agarwal <agarwal1975@g...> |
| Subject: | Re: [Caml-list] Concatenation of static strings? |
I submitted a bug report. On Jan 25, 2008 5:47 AM, Loup Vaillant <loup.vaillant@gmail.com> wrote: > 2008/1/25, Oliver Bandel <oliver@first.in-berlin.de>: > > Zitat von Ashish Agarwal <agarwal1975@gmail.com>: > > > > > 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 = <fun> > # 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 >