diff options
author | Victor Stinner <vstinner@wyplay.com> | 2012-03-13 18:12:23 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@wyplay.com> | 2012-03-13 18:12:23 (GMT) |
commit | bd273c1ec320e3cfda41e5739180d86e052cbc80 (patch) | |
tree | af8bf6161c70d7b869193c9b0b6b39f10797dde2 /Python/pytime.c | |
parent | 87adda502ae0cd113215a1b6800fcb5f88ef394b (diff) | |
download | cpython-bd273c1ec320e3cfda41e5739180d86e052cbc80.zip cpython-bd273c1ec320e3cfda41e5739180d86e052cbc80.tar.gz cpython-bd273c1ec320e3cfda41e5739180d86e052cbc80.tar.bz2 |
Issue #14180: Fix an invalid rounding when compiler optimization are enabled
Use volatile keyword to disable localy unsafe float optimizations.
Diffstat (limited to 'Python/pytime.c')
-rw-r--r-- | Python/pytime.c | 4 |
1 files changed, 3 insertions, 1 deletions
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); |