Commit bd273c1e authored by Victor Stinner's avatar Victor Stinner

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

Use volatile keyword to disable localy unsafe float optimizations.
parent 87adda50
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment