Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1efbeba

Browse files
committed
Try to fix test_time.test_AsSecondsDouble() on "x86 Gentoo Non-Debug with X 3.x" buildbot
Use volatile keyword in _PyTime_Round()
1 parent 350b518 commit 1efbeba

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Python/pytime.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,17 @@ _PyTime_RoundHalfEven(double x)
7575
static double
7676
_PyTime_Round(double x, _PyTime_round_t round)
7777
{
78+
/* volatile avoids optimization changing how numbers are rounded */
79+
volatile double d;
80+
81+
d = x;
7882
if (round == _PyTime_ROUND_HALF_EVEN)
79-
return _PyTime_RoundHalfEven(x);
83+
d = _PyTime_RoundHalfEven(d);
8084
else if (round == _PyTime_ROUND_CEILING)
81-
return ceil(x);
85+
d = ceil(d);
8286
else
83-
return floor(x);
87+
d = floor(d);
88+
return d;
8489
}
8590

8691
static int

0 commit comments

Comments
 (0)