From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=AWL,HTML_MESSAGE, MAILTO_TO_SPAM_ADDR,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 56A2FBC6B for ; Sat, 26 Jan 2008 14:27:48 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAC7EmkfRVYC9kmdsb2JhbACCPDSNOQEBAQEHAgYJChaVDYcC X-IronPort-AV: E=Sophos;i="4.25,254,1199660400"; d="scan'208";a="21828264" Received: from fk-out-0910.google.com ([209.85.128.189]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Jan 2008 14:27:48 +0100 Received: by fk-out-0910.google.com with SMTP id b27so960837fka.11 for ; Sat, 26 Jan 2008 05:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=gOnhIhcqH3woMDXgwwi4zbZsjMTUEBD6kfMsk4pxxHM=; b=Y40wVFQL0P0cucS1HUE4ctFEaAMlu9WVJjVM99bFA8ZatGxR2mOGkE7Ol1NAkoFCkwVyVC7PT463GgFCRhrCi2veLncoFNw90z72XHlhtkGWsLDhanuV53N/tIpsq5ZRbHvUJSCdM+qafvsE7hgje2utLBPW6NurPo9zAQG5Ozg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=J3aFhZcRywNOfTg0Vl153oCWQ4WfODJPnTU1Lo1jYO4131SYhOnVPTcyFFknYeT4NBRWaVruiylC4IDoWO/CFE7IHuL7qqhTKPqzY3GiRJ0w+4PboOEFCBGWsyz4RYfFF0Pc6s+vamQUvULjIy1zndOe1Wl8MFay0aT5MxBgrfQ= Received: by 10.78.201.2 with SMTP id y2mr4487795huf.56.1201354067218; Sat, 26 Jan 2008 05:27:47 -0800 (PST) Received: by 10.78.179.4 with HTTP; Sat, 26 Jan 2008 05:27:47 -0800 (PST) Message-ID: Date: Sat, 26 Jan 2008 08:27:47 -0500 From: "Ashish Agarwal" To: "Caml Mailing List" Subject: Re: [Caml-list] Concatenation of static strings? In-Reply-To: <6f9f8f4a0801250247w37d4c66q1b268e47a72ecabf@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1762_2944810.1201354067201" References: <20080119143259.46752d11.mle+ocaml@mega-nerd.com> <53c655920801190255p71346ac9ka45adf0e1cef2d17@mail.gmail.com> <1201226223.479941ef07943@webmail.in-berlin.de> <6f9f8f4a0801250247w37d4c66q1b268e47a72ecabf@mail.gmail.com> X-Spam: no; 0.00; bug:01 bandel:01 in-berlin:01 ocaml:01 toplevel:01 bytecode:01 statically:01 val:01 cheers:01 beginner's:01 ocaml:01 bug:01 bandel:01 in-berlin:01 toplevel:01 ------=_Part_1762_2944810.1201354067201 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 > ------=_Part_1762_2944810.1201354067201 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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

------=_Part_1762_2944810.1201354067201--