From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7GGDKDn024625 for ; Tue, 16 Aug 2011 18:13:21 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AosBADaWSk7RVdg2kGdsb2JhbABBqDAIFAEBAQEJCQ0HFAQhgUABAQEBAgESAiwBGx0BAwELBgULDS4iAREBBQEcBhMih06bUwqMN4JVhTc7iG0CAwaGQgSHWYs5jFk8g2U X-IronPort-AV: E=Sophos;i="4.68,234,1312149600"; d="scan'208";a="105604692" Received: from mail-qw0-f54.google.com ([209.85.216.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 16 Aug 2011 18:13:20 +0200 Received: by qwc9 with SMTP id 9so61597qwc.27 for ; Tue, 16 Aug 2011 09:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=xFbEJuUBZttFpsJY4EoJRuRH78ihRSt+fQYvdbfekis=; b=VHGG1IaZOILvRMQO+3v9H93rlGNzyErn5mhqxvbhuT9Ceqg3JSHsXZa6MXpaOSkFC3 M8Juh17KVCGJaGrfH8e4oCwL9X0VsCJo8t9XsbxIqNfrIqBLvsSA856vgccMq/v2UqIO KYxiDs6mvkHXCeaeS1PWLICH0LwRnyMIfGOVY= MIME-Version: 1.0 Received: by 10.224.203.9 with SMTP id fg9mr3402190qab.314.1313511199013; Tue, 16 Aug 2011 09:13:19 -0700 (PDT) Received: by 10.229.76.229 with HTTP; Tue, 16 Aug 2011 09:13:18 -0700 (PDT) In-Reply-To: <20110816152550.GA21081@annexia.org> References: <20110816152550.GA21081@annexia.org> Date: Tue, 16 Aug 2011 20:13:18 +0400 Message-ID: From: Dmitry Bely To: "Richard W.M. Jones" Cc: Caml List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p7GGDKDn024625 Subject: Re: [Caml-list] Interfacing with C: bad practice On Tue, Aug 16, 2011 at 7:25 PM, Richard W.M. Jones wrote: > On Tue, Aug 16, 2011 at 11:37:03AM +0400, Dmitry Bely wrote: >> C compiler first puts "list" pointer on stack and then calls >> caml_copy_string(*s), potentially invalidating "list". Of course, the >> stack copy of "list" is not registered as a global root so wrp_ml_cons >> gets an invalid value. > > I think this must be a bug in your C compiler.  The address of list is > stashed in the roots struct,so the C compiler should know that list > can be changed by the call to caml_copy_string. Why the compiler should worry about that? It evaluates parameters form right to left and that behavior fully conforms to the C standard (evaluation order is unspecified). > What C compiler / version is this? Microsoft Visual C++ 10.0 ;-) - Dmitry Bely