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.3 required=5.0 tests=SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id A9732BBAF for ; Sun, 14 Jun 2009 19:44:55 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhMCAEbTNEpQW+UCe2dsb2JhbACYRgEBFiQEt3SEDQU X-IronPort-AV: E=Sophos;i="4.42,218,1243807200"; d="scan'208";a="29518280" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 14 Jun 2009 19:44:54 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MFtlE-000498-41 for caml-list@inria.fr; Sun, 14 Jun 2009 17:44:52 +0000 Received: from mit77-4-88-172-144-4.fbx.proxad.net ([88.172.144.4]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Jun 2009 17:44:52 +0000 Received: from vanicat by mit77-4-88-172-144-4.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Jun 2009 17:44:52 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: vanicat@debian.org (=?utf-8?Q?R=C3=A9mi?= Vanicat) Subject: Re: evaluation order Date: Sun, 14 Jun 2009 19:45:24 +0200 Organization: none Message-ID: <87hbyiaevf.dlv@debian.org> References: <4A352717.7020909@univ-savoie.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: mit77-4-88-172-144-4.fbx.proxad.net Mail-Copy-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux) Cancel-Lock: sha1:bv0Vcrm6qmySiyZMTT68n6rLh88= Sender: news X-Spam: no; 0.00; christophe:01 raffalli:01 raffalli:01 univ-savoie:01 ocaml-:01 bytecode:01 nativecode:01 decr:01 ocamlc:01 ocamlopt:01 bug:01 unspecified:01 ocaml:01 bug:01 unspecified:01 Christophe Raffalli writes: > 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 ? Both must follow the specification, but order of evaluation is left unspecified in ocaml, so this difference is not a bug. The bug is in your code that depend of an unspecified feature of one of the compiler. -- RĂ©mi Vanicat