Enforce rounding in rounded_arith_opp to fix incorrect behaviour.#4
Enforce rounding in rounded_arith_opp to fix incorrect behaviour.#4nafur wants to merge 2 commits intoboostorg:developfrom
Conversation
Using clang with optimizations leads to incorrect results under certain circumstances.
|
Hello, @mclow, please, merge this PR. It's still relevant because of MSVC (still reproduced on MSVC 2015) over-optimization, see https://svn.boost.org/trac/boost/ticket/12018. Thank you! |
|
I am adding a CI environment so we can better handle these requests and prove quality of changes. |
|
This breaks test_add: |
jeking3
left a comment
There was a problem hiding this comment.
Please rebase on develop.
|
This feels like a hack. Either the compiler has a working |
A discussion between Florian (corzilius@informatik.rwth-aachen.de) and Guillaume (guillaume.melquiond@inria.fr) lead to the proposed patch. Compiling the code stated below with
clang++ -std=c++11 -O1leads to incorrect behaviour. (arch linux x64, clang 3.4.2, boost 1.55.0)In a nutshell, we compare the results for
41 * 0.1and-(-41 * 0.1)and the resulting intervals turn out to be disjoint, none of them containing4.1. Note that tiny changes to the code (for example changing the order of the assignments) can make the error vanish.Guillaume proposed to either switch to
rounded_transc_stdor addthis->force_roundingto all occurrences of(-x)after a deeper look into the generated assembly. (Thanks for this!) So here is a patch for this change.