diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-09-10 09:48:00 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-09-10 09:48:00 (GMT) |
commit | 1efbebaac2a29ae42f3de8d74071ea2eda660711 (patch) | |
tree | 5e710b0bb6be7904f234130240aee839dbcb36f4 /Python/pytime.c | |
parent | 350b51839aea3f5bd541b960ef1ec1b5a170854a (diff) | |
download | cpython-1efbebaac2a29ae42f3de8d74071ea2eda660711.zip cpython-1efbebaac2a29ae42f3de8d74071ea2eda660711.tar.gz cpython-1efbebaac2a29ae42f3de8d74071ea2eda660711.tar.bz2 |
Try to fix test_time.test_AsSecondsDouble() on "x86 Gentoo Non-Debug with X 3.x" buildbot
Use volatile keyword in _PyTime_Round()
Diffstat (limited to 'Python/pytime.c')
-rw-r--r-- | Python/pytime.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/pytime.c b/Python/pytime.c index 243f756..9470636 100644 --- a/Python/pytime.c +++ b/Python/pytime.c @@ -75,12 +75,17 @@ _PyTime_RoundHalfEven(double x) static double _PyTime_Round(double x, _PyTime_round_t round) { + /* volatile avoids optimization changing how numbers are rounded */ + volatile double d; + + d = x; if (round == _PyTime_ROUND_HALF_EVEN) - return _PyTime_RoundHalfEven(x); + d = _PyTime_RoundHalfEven(d); else if (round == _PyTime_ROUND_CEILING) - return ceil(x); + d = ceil(d); else - return floor(x); + d = floor(d); + return d; } static int |