Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Incorrect floating point optimizations with ocamlopt #7890
Original bug ID: 7890
ocamlopt incorrectly assumes that multiple occurrences of the same floating point expressions necessarily reduce to the same value. This is not always the case since rounding mode can be changed by programs.
Steps to reproduce
Compile files in attached archive with:
Executing ./not_correct or ./correct should give the same result (they do with ocamlc).
Comment author: sfuric
I wasn't aware of this option (there are so many of them).
Currently, OCaml is very consistent w.r.t. this rounding mode business: the standard library provides no way to change the rounding mode, and the optimizer assumes the rounding mode is not changed (unless
If you use external libraries that change the rounding mode, it is your responsibility, or the library's responsibility, to set
This behavior was discussed and agreed on with the members of the Caml Consortium, some of which have a need to change the FP rounding mode but are happy with