summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-09-10 11:48:00 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-09-10 11:48:00 +0200
commit038b36f15b87ad0cb61493ec79b83228990f870a (patch)
tree0046467623a650bab60ac7505bae882c45ffb967 /Python
parent99d1d4f7eb6d1a53991cb7691324f87ab0361f29 (diff)
downloadcpython-038b36f15b87ad0cb61493ec79b83228990f870a.tar.gz
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')
-rw-r--r--Python/pytime.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index 243f756f3d..9470636fdc 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