]> granicus.if.org Git - python/commitdiff
float_divmod(): the code wasn't sick enough to stop the MS optimizer
authorTim Peters <tim.peters@gmail.com>
Thu, 1 Nov 2001 23:59:56 +0000 (23:59 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 1 Nov 2001 23:59:56 +0000 (23:59 +0000)
from optimizing away mod's sign adjustment when mod == 0; so it got
the intended result only in the debug build.

Objects/floatobject.c

index 7e12a09885eaf2e4398faf3a8efe6a1d8a69e138..cdc9620c0204c21ea6227af57ce520175a54ddaa 100644 (file)
@@ -476,7 +476,7 @@ float_divmod(PyObject *v, PyObject *w)
                   fmod returns different results across platforms; ensure
                   it has the same sign as the denominator; we'd like to do
                   "mod = wx * 0.0", but that may get optimized away */
-               mod = 0.0;
+               mod *= mod;  /* hide "mod = +0" from optimizer */
                if (wx < 0.0)
                        mod = -mod;
        }