[Python-checkins] cpython: Issue #14180: Fix an invalid rounding when compiler optimization are enabled

victor.stinner python-checkins at python.org
Tue Mar 13 19:12:25 CET 2012


http://hg.python.org/cpython/rev/9d69a2418d80
changeset:   75595:9d69a2418d80
user:        Victor Stinner <vstinner at wyplay.com>
date:        Tue Mar 13 19:12:23 2012 +0100
summary:
  Issue #14180: Fix an invalid rounding when compiler optimization are enabled

Use volatile keyword to disable localy unsafe float optimizations.

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


diff --git a/Python/pytime.c b/Python/pytime.c
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -102,7 +102,9 @@
 {
     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);

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


More information about the Python-checkins mailing list