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.7 required=5.0 tests=AWL,DNS_FROM_SECURITYSAGE, 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 9588DBBAF for ; Mon, 17 Nov 2008 11:23:14 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvgCAJjUIEnAXQIngWdsb2JhbACTVgEBFiK5a4J5 X-IronPort-AV: E=Sophos;i="4.33,617,1220220000"; d="scan'208";a="17273107" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Nov 2008 11:23:14 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id mAHANDQ8003247 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 17 Nov 2008 11:23:14 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvgCAJjUIElQRFuwgWdsb2JhbACTVgEBFiK5a4J5 X-IronPort-AV: E=Sophos;i="4.33,617,1220220000"; d="scan'208";a="31518090" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 17 Nov 2008 11:23:13 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1L21GB-0005db-II for caml-list@inria.fr; Mon, 17 Nov 2008 10:23:11 +0000 Date: Mon, 17 Nov 2008 10:23:11 +0000 To: caml-list@inria.fr Subject: Is it a bug or just ordinary floating point differences? Message-ID: <20081117102310.GA21299@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at concorde with ID 49214611.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bug:01 ocaml:01 printf:01 printf:01 ocamlopt:01 ocamlopt:01 stdlib:01 bug:01 3600:98 syntactic:01 tracing:01 diff:02 caml:02 compiling:02 output:02 I'm tracing a failure in the Calendar test suite when we are compiling using the OCaml Windows cross-compiler. It comes down to the following piece of test code: ---------------------------------------------------------------------- open Printf let x = 1 * 3600 + 2 * 60 + 3 ;; printf "minutes = %g\n" (float x /. 60.) ;; printf "minutes (immediate) = 62.05 is %b\n" ((float x /. 60.) = 62.05) ;; let m = float x /. 60. ;; printf "minutes (variable) = 62.05 is %b\n" (m = 62.05) ;; ---------------------------------------------------------------------- When this is compiled using ordinary ocamlopt on a variety of platforms (32 & 64 bit Linux, and 32 bit Windows), I always get the following output: minutes = 62.05 minutes (immediate) = 62.05 is true minutes (variable) = 62.05 is true However my Windows cross-compiler (only) prints this: minutes = 62.05 minutes (immediate) = 62.05 is false minutes (variable) = 62.05 is true Interestingly the generated assembly is pretty much identical in all cases, excepting whitespace and some non-essential syntactic changes: http://www.annexia.org/tmp/test_float-i686-crosswin-3.11.0.s Windows cross-compiler 3.11.0+beta1. http://www.annexia.org/tmp/test_float-i686-win-3.10.2.s Windows 32-bit ocamlopt 3.10.2. http://www.annexia.org/tmp/test_float-i686-linux-3.08.3.s Linux 32-bit ocamlopt 3.08.3. As an example, try: diff -ub test_float-i686-crosswin-3.11.0.s test_float-i686-win-3.10.2.s There don't seem to be any calls to the stdlib (eg. to caml_compare) which could cause a difference. Obviously I'm aware of the difference between storing a floating point value into a variable versus keeping a (higher precision) immediate value in an x86 register, but the lack of any difference in the assembly output makes me suspicious that something else is going on, and that this could be a bug in the cross-compiler. Rich. -- Richard Jones Red Hat