From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7GH92Bo027983 for ; Tue, 16 Aug 2011 19:09:02 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjICANOjSk7UGyoFkWdsb2JhbABBmS6PERQBAQEBCQsLBxQDIoFAAQEFOk8LRhSITqtnjXCFaV8EmCyLXQ X-IronPort-AV: E=Sophos;i="4.68,234,1312149600"; d="scan'208";a="116010301" Received: from smtp5-g21.free.fr ([212.27.42.5]) by mail1-smtp-roc.national.inria.fr with ESMTP; 16 Aug 2011 19:09:00 +0200 Received: from yeeloong (unknown [82.67.194.89]) by smtp5-g21.free.fr (Postfix) with SMTP id 415E5D48056 for ; Tue, 16 Aug 2011 19:08:53 +0200 (CEST) Received: by yeeloong (sSMTP sendmail emulation); Tue, 16 Aug 2011 19:08:13 +0200 Date: Tue, 16 Aug 2011 19:08:12 +0200 From: rixed@happyleptic.org To: caml-list@inria.fr Message-ID: <20110816170812.GA15913@yeeloong.happyleptic.org> References: <20110816152550.GA21081@annexia.org> <20110816155137.GA18365@ccellier.rd.securactive.lan> <20110816161042.GA31932@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110816161042.GA31932@annexia.org> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] Interfacing with C: bad practice -[ Tue, Aug 16, 2011 at 05:10:42PM +0100, Richard W.M. Jones ]---- > Nevertheless, the C compiler isn't allowed to just push 'list' blindly > onto the stack and assume it doesn't change across the call to > 'caml_copy_string'. For me, wrp_ml_cons(caml_copy_string(*s), list); with caml_copy_string changing list, fall under the rule that a value shall not be modified twice between two sequence points. I've just read the relevant parts of the spec and if indeed there is a sequence point between parameters evaluation and the call itself, there are not between the evaluation of the parameters themself (which order of evaluation is, of course, undefined)! Please see for yourself: [#10] The order of evaluation of the function designator, the actual arguments, and subexpressions within the actual arguments is unspecified, but there is a sequence point before the actual call. So it seams to me that the compiler if entitled to evaluate list first, and then evaluate caml_copy_string(*s), provided it "fully" evaluates them before the actual jump to wrp_ml_cons. This is unrelated to wether the address of list is available to caml_copy_string or anything; the programmer is supposed to know that the order of evaluation is undefined and write his code accordingly.