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=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 731F0BBAF for ; Sun, 14 Jun 2009 21:35:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhgDAIftNErUnwckaGdsb2JhbACCHpYoDQoJBxUEuC2EDQU X-IronPort-AV: E=Sophos;i="4.42,218,1243807200"; d="scan'208";a="41770429" Received: from relay.ptn-ipout02.plus.net ([212.159.7.36]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Jun 2009 21:35:42 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhwFAAPuNErUnw6S/2dsb2JhbACCHs8ThA0F Received: from ptb-relay02.plus.net ([212.159.14.146]) by relay.ptn-ipout02.plus.net with ESMTP; 14 Jun 2009 20:35:41 +0100 Received: from [87.115.156.101] (helo=[192.168.2.7]) by ptb-relay02.plus.net with esmtp (Exim) id 1MFvUT-0005L4-Cf for caml-list@yquem.inria.fr; Sun, 14 Jun 2009 20:35:41 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] evaluation order Date: Sun, 14 Jun 2009 20:40:47 +0100 User-Agent: KMail/1.9.9 References: <4A352717.7020909@univ-savoie.fr> In-Reply-To: <4A352717.7020909@univ-savoie.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906142040.47645.jon@ffconsultancy.com> X-Plusnet-Relay: 8d368a901c8add40298186e5d6c29a0b X-Spam: no; 0.00; christophe:01 raffalli:01 ocaml-:01 bytecode:01 nativecode:01 decr:01 ocamlc:01 ocamlopt:01 bug:01 2009:98 frog:98 wrote:01 caml-list:01 arithmetic:01 undefined:01 On Sunday 14 June 2009 17:36:39 Christophe Raffalli wrote: > Hello, > > In OCaml-3.11.1 (I did not try other version), > the following code print 0 when compiled in bytecode and 1 in nativecode > for obvious reason of different evaluation order in the pair ... > > > let ptr = ref 0 > let fn b = > if b then incr ptr else decr ptr > let c = fn true, !ptr > let _ = print_int (snd c); print_newline () > > Is any difference between ocamlc and ocamlopt a bug ? Not at all, no. They are expected to have different behaviour with respect to floating point arithmetic. In this case, they have chosen to evaluate subexpressions in a different order, which is fine because the order of evaluation is officially undefined. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e