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,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 C982EBC6B for ; Fri, 25 Jan 2008 11:47:39 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAPNMmUfRVYT5kmdsb2JhbACQJAEBAQEHBAQJChaWK4dQ X-IronPort-AV: E=Sophos;i="4.25,249,1199660400"; d="scan'208";a="21790277" Received: from an-out-0708.google.com ([209.85.132.249]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Jan 2008 11:47:39 +0100 Received: by an-out-0708.google.com with SMTP id b15so168420ana.102 for ; Fri, 25 Jan 2008 02:47:38 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=SPuRvW9Oxc+6Yg61hB6S49f0znLAPn3CC0BKEWah4f4=; b=v9+4Bf9wuWk9FlSth8Pu/puBuMhHeqdHiPbcknfFx81hcGg22KYUJ7vDQ0mfna2vP36LbROgQVIwvomPKKqJ585J2c/iDi8wbYsVrA9+Bm2o9NBEwTb5FhbMQhGahprs2kK1+PRqlqgzg2WG8U3V82qlPp/p9tCe4/BO0Gl7680= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=kT3Gepz10dh95mOM1hUTeEbR7T7ZIAUScWHoesi2z9HuhA8zXhdCvKtPzUXrEPEMpYqEBT+S6hBAOOkaz+G9w35iWu4968jVpr1rMJ81U0M5TNLcp78VPIkhXHEWiN+zZjztjFiVysO6tVyVx5GVZCOO5PTe2prglFjGLafIDSY= Received: by 10.100.232.13 with SMTP id e13mr3889950anh.37.1201258057864; Fri, 25 Jan 2008 02:47:37 -0800 (PST) Received: by 10.100.248.15 with HTTP; Fri, 25 Jan 2008 02:47:37 -0800 (PST) Message-ID: <6f9f8f4a0801250247w37d4c66q1b268e47a72ecabf@mail.gmail.com> Date: Fri, 25 Jan 2008 11:47:37 +0100 From: "Loup Vaillant" To: "Oliver Bandel" Subject: Re: [Caml-list] Concatenation of static strings? Cc: caml-list@yquem.inria.fr In-Reply-To: <1201226223.479941ef07943@webmail.in-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080119143259.46752d11.mle+ocaml@mega-nerd.com> <53c655920801190255p71346ac9ka45adf0e1cef2d17@mail.gmail.com> <1201226223.479941ef07943@webmail.in-berlin.de> X-Spam: no; 0.00; bandel:01 in-berlin:01 ocaml:01 toplevel:01 bytecode:01 statically:01 val:01 cheers:01 1975:98 char:01 char:01 oliver:01 oliver:01 caml-list:01 strings:01 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