New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect floating point optimizations with ocamlopt #7890
Comments
Comment author: @lpw25 I could be wrong, but I thought that was what the compiler's -no-float-const-prop option was for. So I don't think this is a bug, but the expected behaviour. |
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 |
Original bug ID: 7890
Reporter: sfuric
Status: new
Resolution: open
Priority: normal
Severity: major
Version: 4.07.0
Category: back end (clambda to assembly)
Related to: #3526
Monitored by: @nojb @shindere @gasche @yakobowski
Bug description
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:
ocamlopt -c roundingMode_stubs.c
ocamlopt -c roundingMode.mli
ocamlopt -c roundingMode.ml
ocamlopt roundingMode.cmx roundingMode_stubs.o testRounding.ml -o not_correct
ocamlopt roundingMode.cmx roundingMode_stubs.o testRounding_modified.ml -o correct
Executing ./not_correct or ./correct should give the same result (they do with ocamlc).
File attachments
The text was updated successfully, but these errors were encountered: