]> granicus.if.org Git - python/commitdiff
Issue #22117: Try to fix rounding in conversion from Python double to _PyTime_t
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 08:22:16 +0000 (10:22 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 08:22:16 +0000 (10:22 +0200)
using the C volatile keyword.

Python/pytime.c

index 98f29acc38bd7fb31d4a37a8f576220c23788174..5bf8c568e7b6a88ec9436a399cc3f08b2248bf09 100644 (file)
@@ -207,7 +207,8 @@ int
 _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);