From bd273c1ec320e3cfda41e5739180d86e052cbc80 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 13 Mar 2012 19:12:23 +0100 Subject: Issue #14180: Fix an invalid rounding when compiler optimization are enabled Use volatile keyword to disable localy unsafe float optimizations. --- Python/pytime.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/pytime.c b/Python/pytime.c index 75d80e2..e7dadc7 100644 --- a/Python/pytime.c +++ b/Python/pytime.c @@ -102,7 +102,9 @@ _PyTime_ObjectToDenominator(PyObject *obj, time_t *sec, long *numerator, { assert(denominator <= LONG_MAX); if (PyFloat_Check(obj)) { - double d, intpart, floatpart, err; + double d, intpart, err; + /* volatile avoids unsafe optimization on float enabled by gcc -O3 */ + volatile double floatpart; d = PyFloat_AsDouble(obj); floatpart = modf(d, &intpart); -- cgit v0.12