diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-09-19 11:39:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-09-19 11:39:16 (GMT) |
commit | 026977717eea2382590547d476abcb0c74391358 (patch) | |
tree | 3bf65b7b4e8e5eb40d666306d63221a3f8ced8bf /Objects | |
parent | d644d5eefa1d18a21cb89b63d488ce8bea1d548c (diff) | |
parent | 5783fd2c58d068329c1ddeaea1db8acca5e2577b (diff) | |
download | cpython-026977717eea2382590547d476abcb0c74391358.zip cpython-026977717eea2382590547d476abcb0c74391358.tar.gz cpython-026977717eea2382590547d476abcb0c74391358.tar.bz2 |
Merge 3.5
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 40da0b1..5f22455 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4495,11 +4495,13 @@ _PyLong_GCD(PyObject *aarg, PyObject *barg) simple: assert(Py_REFCNT(a) > 0); assert(Py_REFCNT(b) > 0); -#if LONG_MAX >> 2*PyLong_SHIFT +/* Issue #24999: use two shifts instead of ">> 2*PyLong_SHIFT" to avoid + undefined behaviour when LONG_MAX type is smaller than 60 bits */ +#if LONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT /* a fits into a long, so b must too */ x = PyLong_AsLong((PyObject *)a); y = PyLong_AsLong((PyObject *)b); -#elif defined(PY_LONG_LONG) && PY_LLONG_MAX >> 2*PyLong_SHIFT +#elif defined(PY_LONG_LONG) && PY_LLONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT x = PyLong_AsLongLong((PyObject *)a); y = PyLong_AsLongLong((PyObject *)b); #else @@ -4516,9 +4518,9 @@ simple: y = x % y; x = t; } -#if LONG_MAX >> 2*PyLong_SHIFT +#if LONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT return PyLong_FromLong(x); -#elif defined(PY_LONG_LONG) && PY_LLONG_MAX >> 2*PyLong_SHIFT +#elif defined(PY_LONG_LONG) && PY_LLONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT return PyLong_FromLongLong(x); #else # error "_PyLong_GCD" |