]> granicus.if.org Git - python/commitdiff
Try to fix test_time.test_AsSecondsDouble() on "x86 Gentoo Non-Debug with X 3.x"...
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 10 Sep 2015 09:48:00 +0000 (11:48 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 10 Sep 2015 09:48:00 +0000 (11:48 +0200)
Use volatile keyword in _PyTime_Round()

Python/pytime.c

index 243f756f3d404fef3f8fbc0aa84642dd24d6532d..9470636fdc7e32bbe2358e26685583a13f4d0527 100644 (file)
@@ -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