From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id BAE007ED5C for ; Mon, 6 Aug 2012 12:04:28 +0200 (CEST) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of dmitry.bely@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="dmitry.bely@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of dmitry.bely@gmail.com designates 209.85.220.182 as permitted sender) identity=mailfrom; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="dmitry.bely@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vc0-f182.google.com) identity=helo; client-ip=209.85.220.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="dmitry.bely@gmail.com"; x-sender="postmaster@mail-vc0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhYCAPp4H1DRVdy2m2dsb2JhbABFuTYIIgEBAQEBCAkLCRQngjkCLAEbHgMSEF0BEQEFAVeHWwEDDJoegmEJA4wjgnGETgoZJw1XiHEBBQyPJoMcA4hHjQKOLz6EAw X-IronPort-AV: E=Sophos;i="4.77,717,1336341600"; d="scan'208";a="169175758" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 06 Aug 2012 12:04:28 +0200 Received: by vcbgb22 with SMTP id gb22so4198927vcb.27 for ; Mon, 06 Aug 2012 03:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=zx4nW+f7x2EdxiOVb6dE3zYG2vJGK9SaWDqBF2opmHg=; b=I0qGPOEzV1SBIFeEGHxgXirOPrHhVWf+8axkqrpkwDYilBFRVGkmqqSe/HKS15tY+f mb9dNHWdwMrmEBekMOqp7jF5hmq+YYClsuRw8OgvElDsqJMSac8pXLUiwGZosgpatNZP I3A8pNR2JV3HzjfOi2V739ritxYlkeZxaOeFYv0nNdoMeZOtLurcAT7kJB4pyrpk4Flm gwMjpuZxElPwf8S67k1eLQ7OkY2QWoG3PwoV4CvtGGmgJYei9FCwcUtwLVy8wJTY06E5 0PJlyoYlnqcL9JFcdwVUzQQh3Tm8y8F4WoKZ4Qk5TBtSgTqGzTQrwKzWlkKBJx2xd3dx eIuA== MIME-Version: 1.0 Received: by 10.58.74.198 with SMTP id w6mr8657106vev.22.1344247467328; Mon, 06 Aug 2012 03:04:27 -0700 (PDT) Received: by 10.220.117.66 with HTTP; Mon, 6 Aug 2012 03:04:27 -0700 (PDT) Date: Mon, 6 Aug 2012 14:04:27 +0400 Message-ID: From: Dmitry Bely To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: [Caml-list] Compiler bug? Trying to catch some very rare floating-point related bug I've realized that I probably don't understand some basic things about OCaml execution model. Let's consider the simplest function: let add1 x = x +. 1. For x86 it is compiled as .CODE ALIGN 4 PUBLIC _camlTest__add1_1008 _camlTest__add1_1008: sub esp, 8 L100: mov ebx, eax L101: mov eax, _caml_young_ptr sub eax, 12 mov _caml_young_ptr, eax cmp eax, _caml_young_limit jb L102 lea eax, [eax+4] mov DWORD PTR [eax-4],2301 fld1 fadd REAL8 PTR [ebx] fstp REAL8 PTR [eax] add esp, 8 ret L102: call _caml_call_gc L103: jmp L101 X parameter is passed as a pointer to float value ([eax] which is immediately saved to [ebx]). But If GC happens (L102), float value can be moved around the OCaml heap and [ebx] become invalid, right? So the generated code is just wrong. Am I missing something? - Dmitry Bely