|
Boost Users : |
Subject: [Boost-users] [Interval] Help debugging compiler optimization
From: Tim van Erven (tim_at_[hidden])
Date: 2018-03-02 16:17:38
Dear all,
I am trying to understand why I am getting different numerical results
with the interval library depending on the optimization level of the
compiler.
I am attaching the smallest example I have been able to create:
# On my Mac laptop
Apple LLVM version 9.0.0 (clang-900.0.39.2)
boost 1.66 (installed via homebrew)
$ g++ foo.cpp -o foo
$ ./foo
third1 = 0.3333333333333333148296162562473909929394721984863281250000000000
third2 = 0.3333333333333333148296162562473909929394721984863281250000000000
v1 =
(0.9999999999999998889776975374843459576368331909179687500000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
v2 =
(0.9999999999999998889776975374843459576368331909179687500000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
$ g++ -O2 foo.cpp -o foo
$ ./foo
third1 = 0.3333333333333333148296162562473909929394721984863281250000000000
third2 = 0.3333333333333333148296162562473909929394721984863281250000000000
v1 =
(1.0000000000000000000000000000000000000000000000000000000000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
v2 =
(1.0000000000000000000000000000000000000000000000000000000000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
I would expect to get the same output in both cases, but the lower
end-points are different in the second case, and seem wrong to me since
third2 * 3.0 < 1.0.
# On my Linux machine the effect is different:
gcc version 5.4.0 20160609
boost 1.58 on Ubuntu 16.04.9
$ g++ foo.cpp -o foo
$ ./foo
third1 = 0.3333333333333333148296162562473909929394721984863281250000000000
third2 = 0.3333333333333333148296162562473909929394721984863281250000000000
v1 =
(0.9999999999999998889776975374843459576368331909179687500000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
v2 =
(0.9999999999999998889776975374843459576368331909179687500000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
$ g++ -O2 foo.cpp -o foo
$ ./foo
third1 = 0.3333333333333333148296162562473909929394721984863281250000000000
third2 = 0.3333333333333333148296162562473909929394721984863281250000000000
v1 =
(0.9999999999999998889776975374843459576368331909179687500000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
v2 =
(1.0000000000000000000000000000000000000000000000000000000000000000,1.0000000000000000000000000000000000000000000000000000000000000000)
Can anyone explain what is going on?
Thanks in advance,
Tim
-- Tim van Erven<tim_at_[hidden]> www.timvanerven.nl
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net