diff options
| author | Victor Stinner <vstinner@wyplay.com> | 2012-03-13 19:12:23 +0100 |
|---|---|---|
| committer | Victor Stinner <vstinner@wyplay.com> | 2012-03-13 19:12:23 +0100 |
| commit | 75ff7e8c4aa9633a8c87788c24ab8335fa1dd698 (patch) | |
| tree | 6110eb96e1d329650d23a0e4e3382f61c97654bb /Python/pytime.c | |
| parent | 6659050c5d2c32c9f1983fb1bf7392b606335dc5 (diff) | |
| download | cpython-75ff7e8c4aa9633a8c87788c24ab8335fa1dd698.tar.gz | |
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 75d80e2576..e7dadc7605 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); |
