1. andrea_crotti
  2. cpython

Commits

Victor Stinner  committed 9d69a24

Issue #14180: Fix an invalid rounding when compiler optimization are enabled

Use volatile keyword to disable localy unsafe float optimizations.

  • Participants
  • Parent commits 760cf15
  • Branches default

Comments (0)

Files changed (1)

File Python/pytime.c

View file
  • Ignore whitespace
 {
     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);