Control: tags -1 + patch Here is a patch that contains the two upstream commits that fix the issue. I tested it on i386. Yaroslav, do you mind if I upload the fix or do you want?
Best, Tobias
>From afeb193f97a5f7b85f7128f252b6071127e4031a Mon Sep 17 00:00:00 2001 From: Stefan Behnel <stefan...@behnel.de> Date: Sun, 27 Nov 2016 12:03:06 +0100 Subject: [PATCH] Try to fix #1530: left-shift operations by more than 31 bits wrap around on 32bit systems --- Cython/Utility/Optimize.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cython/Utility/Optimize.c b/Cython/Utility/Optimize.c index 9de085b..4fed9d9 100644 --- a/Cython/Utility/Optimize.c +++ b/Cython/Utility/Optimize.c @@ -596,7 +596,7 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO } return PyInt_FromLong(x); {{elif op == 'Lshift'}} - if (likely(a == (a << b) >> b)) { + if (likely(b < sizeof(long)*8 && a == (a << b) >> b) || !a) { return PyInt_FromLong(a {{c_op}} b); } {{else}} @@ -685,12 +685,12 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, CYTHO x = a {{c_op}} b; {{if op == 'Lshift'}} #ifdef HAVE_LONG_LONG - if (unlikely(a != x >> b)) { + if (unlikely(!(b < sizeof(long)*8 && a == x >> b)) && a) { ll{{ival}} = {{ival}}; goto long_long; } #else - if (likely(a == x >> b)) /* execute return statement below */ + if (likely(b < sizeof(long)*8 && a == x >> b) || !a) /* execute return statement below */ #endif {{endif}} {{endif}} >From ea1939d4e88c598dd9685ca5372d6da73e0b44b0 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw <rober...@gmail.com> Date: Mon, 21 Nov 2016 22:35:40 -0800 Subject: [PATCH] Fix some trailing Ls in doctsts. --- tests/run/pyintop.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run/pyintop.pyx b/tests/run/pyintop.pyx index b9fba34..8ca77ae 100644 --- a/tests/run/pyintop.pyx +++ b/tests/run/pyintop.pyx @@ -159,16 +159,16 @@ def lshift_int(obj): >>> bigints(lshift_int(-32)) (-256, -68719476736, -295147905179352825856, -340282366920938463463374607431768211456) - >>> (2**28) << 3 + >>> bigint((2**28) << 3) 2147483648 >>> bigints(lshift_int(2**28)) (2147483648, 576460752303423488, 2475880078570760549798248448, 2854495385411919762116571938898990272765493248) - >>> (-2**28) << 3 + >>> bigint((-2**28) << 3) -2147483648 >>> bigints(lshift_int(-2**28)) (-2147483648, -576460752303423488, -2475880078570760549798248448, -2854495385411919762116571938898990272765493248) - >>> (2**30) << 3 + >>> bigint((2**30) << 3) 8589934592 >>> bigints(lshift_int(2**30)) (8589934592, 2305843009213693952, 9903520314283042199192993792, 11417981541647679048466287755595961091061972992)