Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007890OCamlback end (clambda to assembly)public2019-01-02 12:122019-01-04 18:12
Reportersfuric 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Product Version4.07.0 
Target VersionFixed in Version 
Summary0007890: Incorrect floating point optimizations with ocamlopt
Descriptionocamlopt 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 ReproduceCompile 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).
TagsNo tags attached.
Attached Filestgz file icon rounding.tgz [^] (1,096 bytes) 2019-01-02 12:12

- Relationships

-  Notes
(0019522)
lpw25 (developer)
2019-01-02 14:00

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.
(0019523)
sfuric (reporter)
2019-01-02 14:30
edited on: 2019-01-02 14:36

I wasn't aware of this option (there are so many of them).
But I would certainly have preferred the opposite default behavior, i.e. no floating point "optimizations" by default, because it breaks functional abstraction (my example precisely shows that by factorizing out common operations the behavior of the program is changed), and it also breaks compatibility with ocamlc.
Why not having a -float-const-prop option instead, I mean require users to explicitly ask for constant propagation (knowing that it may change the semantics)?


- Issue History
Date Modified Username Field Change
2019-01-02 12:12 sfuric New Issue
2019-01-02 12:12 sfuric File Added: rounding.tgz
2019-01-02 14:00 lpw25 Note Added: 0019522
2019-01-02 14:30 sfuric Note Added: 0019523
2019-01-02 14:36 sfuric Note Edited: 0019523 View Revisions


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker