caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] float numbers problem (CVS version of ocamlopt)
@ 2003-06-03 11:55 Sebastien Briais
  2003-06-04 13:12 ` Sebastien Briais
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sebastien Briais @ 2003-06-03 11:55 UTC (permalink / raw)
  To: caml-list

Hello,

when doing a little program in ocaml that uses float numbers,
I found something that sounds like a bug in the native compiler.

I have a PC (Pentium IV) with a RedHat 8.0 and the CVS version of ocaml 
: 3.06+34

I reduce the bug to the following file:

-- start of file toto.ml

let square x = x *. x

let _ =
  let x = 1.84066666666666823 in
  let x0 = 1.16666666666666674 in
  let dx = 0.674000000000001487 in
    print_float (x -. x0);
    print_newline();
    print_float (square (x -. x0));
    print_newline();
    print_float dx;
    print_newline();
    print_float (square dx);
    print_newline();

-- end of file

now, I compile this file with the bytecode compiler and then the native 
compiler
(and execute the resulting file)

bash-2.05b$ ocamlc -o toto toto.ml
bash-2.05b$ ./toto
0.674000000000001487
0.454276000000002012
0.674000000000001487
0.454276000000002012

bash-2.05b$ ocamlopt -o toto.opt toto.ml
bash-2.05b$ ./toto.opt
0.674000000000001487
nan.
0.674000000000001487
nan.

The results obtained with the native code compiler are very strange, 
aren't they ?
Does anyone else has this problem ?

I have to say that I also tried with the official release 3.06 of ocaml 
and this worked perfectly.
So, this strange behaviour has appeared after the latest official 
release of ocaml (3.06).
(That's why I did not post to the bug tracker since it is not a bug of 
an official release)

Regards

Sébastien



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] float numbers problem (CVS version of ocamlopt)
  2003-06-03 11:55 [Caml-list] float numbers problem (CVS version of ocamlopt) Sebastien Briais
@ 2003-06-04 13:12 ` Sebastien Briais
  2003-06-06 23:42 ` John Max Skaller
  2003-06-10 11:46 ` Xavier Leroy
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastien Briais @ 2003-06-04 13:12 UTC (permalink / raw)
  To: caml-list

Hello,

concerning this problem, I have made some new experiments and I suspect 
the inlining to be bugged.

I changed a bit my sample file to:


-- start of toto.ml

let square x = x *. x

let _ =
 let x = 1.84066666666666823 in
 let x0 = 1.16666666666666674 in
 let dx = 0.674000000000001487 in
 let dx2 =  0.674000000000001487 *.  0.674000000000001487  in
   print_float (x -. x0);
   print_newline();
   print_float (square (x -. x0));
   print_newline();
   print_float dx;
   print_newline();
   print_float (square dx);
   print_newline();
   print_float dx2;
   print_newline();

-- end of toto.ml

bash-2.05b$ ocamlopt -o toto.opt toto.ml
bash-2.05b$ ./toto.opt
0.674000000000001487
nan.
0.674000000000001487
nan.
0.454276000000002012

and now, without inlining:

bash-2.05b$ ocamlopt -inline 0 -o toto.opt toto.ml
bash-2.05b$ ./toto.opt
0.674000000000001487
0.454276000000002012
0.674000000000001487
0.454276000000002012
0.454276000000002012

it works !!

hope that helps the debugging process

Regards

Sébastien


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] float numbers problem (CVS version of ocamlopt)
  2003-06-03 11:55 [Caml-list] float numbers problem (CVS version of ocamlopt) Sebastien Briais
  2003-06-04 13:12 ` Sebastien Briais
@ 2003-06-06 23:42 ` John Max Skaller
  2003-06-10 11:46 ` Xavier Leroy
  2 siblings, 0 replies; 4+ messages in thread
From: John Max Skaller @ 2003-06-06 23:42 UTC (permalink / raw)
  To: Sebastien Briais; +Cc: caml-list

Sebastien Briais wrote:

> Hello,
> 
> when doing a little program in ocaml that uses float numbers,
> I found something that sounds like a bug in the native compiler.
> 
> I have a PC (Pentium IV) with a RedHat 8.0 and the CVS version of ocaml 
> : 3.06+34


Objective Caml version 3.06+31 (2003-05-02)

Same result in +31.


> bash-2.05b$ ocamlc -o toto toto.ml
> bash-2.05b$ ./toto
> 0.674000000000001487
> 0.454276000000002012
> 0.674000000000001487
> 0.454276000000002012
> 
> bash-2.05b$ ocamlopt -o toto.opt toto.ml
> bash-2.05b$ ./toto.opt
> 0.674000000000001487
> nan.
> 0.674000000000001487
> nan.



-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] float numbers problem (CVS version of ocamlopt)
  2003-06-03 11:55 [Caml-list] float numbers problem (CVS version of ocamlopt) Sebastien Briais
  2003-06-04 13:12 ` Sebastien Briais
  2003-06-06 23:42 ` John Max Skaller
@ 2003-06-10 11:46 ` Xavier Leroy
  2 siblings, 0 replies; 4+ messages in thread
From: Xavier Leroy @ 2003-06-10 11:46 UTC (permalink / raw)
  To: Sebastien Briais; +Cc: caml-list

> when doing a little program in ocaml that uses float numbers,
> I found something that sounds like a bug in the native compiler.

Yes, it's a bug in the x86 code generator.  Thanks for reporting it.

> (That's why I did not post to the bug tracker since it is not a bug of 
> an official release)

All bug reports should go to the bug tracking system, even for
non-released versions.  That's the best way to ensure that the bug
will be fixed by the next official release :-)

- Xavier Leroy

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-06-10 11:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-03 11:55 [Caml-list] float numbers problem (CVS version of ocamlopt) Sebastien Briais
2003-06-04 13:12 ` Sebastien Briais
2003-06-06 23:42 ` John Max Skaller
2003-06-10 11:46 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).