Index: Python/pymath.c =================================================================== --- Python/pymath.c (revision 67602) +++ Python/pymath.c (working copy) @@ -1,5 +1,11 @@ #include "Python.h" +double Py_force_to_memory(double x) +{ + volatile double y = x; + return y; +} + #ifndef HAVE_HYPOT double hypot(double x, double y) { Index: Include/pymath.h =================================================================== --- Include/pymath.h (revision 67602) +++ Include/pymath.h (working copy) @@ -145,6 +145,12 @@ #define Py_NAN (Py_HUGE_VAL * 0.) #endif +PyAPI_FUNC(double) Py_force_to_memory(double); + +#ifndef Py_FORCE_TO_MEMORY +#define Py_FORCE_TO_MEMORY(x) Py_force_to_memory(x) +#endif + /* Py_OVERFLOWED(X) * Return 1 iff a libm function overflowed. Set errno to 0 before calling * a libm function, and invoke this macro after, passing the function Index: Modules/cmathmodule.c =================================================================== --- Modules/cmathmodule.c (revision 67602) +++ Modules/cmathmodule.c (working copy) @@ -478,7 +478,8 @@ r.imag = l*sin(z.imag); } /* detect overflow, and set errno accordingly */ - if (Py_IS_INFINITY(r.real) || Py_IS_INFINITY(r.imag)) + if (Py_IS_INFINITY(Py_FORCE_TO_MEMORY(r.real)) || + Py_IS_INFINITY(Py_FORCE_TO_MEMORY(r.imag))) errno = ERANGE; else errno = 0;