[Python-checkins] cpython: Issue #22117: Try to fix rounding in conversion from Python double to _PyTime_t

victor.stinner python-checkins at python.org
Mon Mar 30 10:22:23 CEST 2015


https://hg.python.org/cpython/rev/e00b581a65ec
changeset:   95286:e00b581a65ec
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Mar 30 10:22:16 2015 +0200
summary:
  Issue #22117: Try to fix rounding in conversion from Python double to _PyTime_t
using the C volatile keyword.

files:
  Python/pytime.c |  3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)


diff --git a/Python/pytime.c b/Python/pytime.c
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -207,7 +207,8 @@
 _PyTime_FromSecondsObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round)
 {
     if (PyFloat_Check(obj)) {
-        double d, err;
+        /* volatile avoids unsafe optimization on float enabled by gcc -O3 */
+        volatile double d, err;
 
         /* convert to a number of nanoseconds */
         d = PyFloat_AsDouble(obj);

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list