Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Dmitry Bely" <dmitry.bely@gmail.com>
To: "Sebastien Ferre" <Sebastien.Ferre@irisa.fr>
Cc: ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Floating exception
Date: Mon, 26 Nov 2007 20:56:27 +0300	[thread overview]
Message-ID: <90823c940711260956r137e8abdg83f03969c8fece6a@mail.gmail.com> (raw)
In-Reply-To: <474B019F.90102@irisa.fr>

On Nov 26, 2007 8:25 PM, Sebastien Ferre <Sebastien.Ferre@irisa.fr> wrote:

> I've got the same problem with the simplest program,
> the "hello world" :
>
> let _ = print_string "Hello world!\n"
>
>
> * Machine where compiled (in native code):
>
> Linux version 2.6.20-1.2952.fc6
> (brewbuilder@ls20-bc1-14.build.redhat.com) (gcc
> version 4.1.1 20070105 (Red Hat 4.1.1-51)) #1 SMP Wed May 16 18:59:18
> EDT 2007
> Intel(R) Core(TM) Duo CPU      U2500  @ 1.20GHz
>
>
> * Machine where execution produces "Floating exception"

It could be Ocaml runtime initialization. I've faced it under Windows
then loaded Ocaml DLL from Borland C-compiled program. The problem was
that Pervasives.infinity

let infinity =
  float_of_bits 0x7F_F0_00_00_00_00_00_00L

expects (due to float_of_bits) FP control word to be set some specific
way otherwise floating-point exception will occur. I worked around it
as follows:

      const unsigned newState =_EM_DENORMAL|
          _EM_INEXACT|_EM_UNDERFLOW|_EM_OVERFLOW|EM_ZERODIVIDE|_EM_INVALID;
      unsigned oldState = _control87(newState, _MCW_EM);
      caml_startup(argv);
      _control87(oldState, _MCW_EM);

(Don't remember which flags are really necessary - I just duplicated
the default MSVC compiler state that worked)

Probably this is Ocaml bug as its runtime should not depend on the
default state of FP control word and should set in explicitly.

- Dmitry Bely


  reply	other threads:[~2007-11-26 17:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-23 18:08 Sebastien Ferre
2007-11-23 22:36 ` [Caml-list] " Jon Harrop
2007-11-24  8:23   ` Vu Ngoc San
     [not found]     ` <200711242236.24433.jon@ffconsultancy.com>
2007-11-25  8:26       ` Vu Ngoc San
2007-11-25 15:35         ` [Caml-list] Smoke on 3.09.2 Jon Harrop
2007-11-25 18:26           ` Jon Harrop
2007-11-25 20:12             ` Vu Ngoc San
2007-11-25 20:48               ` Jon Harrop
2007-11-25 21:20                 ` Vu Ngoc San
2007-11-25 21:22                   ` Jon Harrop
2007-11-27 10:24   ` [Caml-list] Floating exception Jean-Marc EBER
2007-11-27 11:19     ` Jon Harrop
2007-11-27 13:53       ` Jean-Marc EBER
2007-11-27 15:35       ` Richard Jones
2007-11-27 18:13         ` Jon Harrop
2007-11-28 10:47       ` Vu Ngoc San
2007-11-28 14:48         ` Jon Harrop
2007-11-29 14:39         ` Vu Ngoc San
     [not found] ` <1195900308.7242.19.camel@localhost>
2007-11-26 17:25   ` Sebastien Ferre
2007-11-26 17:56     ` Dmitry Bely [this message]
2007-11-27  0:01     ` Richard Jones
2007-11-27  6:56       ` Sebastien Ferre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90823c940711260956r137e8abdg83f03969c8fece6a@mail.gmail.com \
    --to=dmitry.bely@gmail.com \
    --cc=Sebastien.Ferre@irisa.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox