diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2016-02-29 08:24:37 -0800 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2016-03-24 14:26:11 +0100 |
commit | b07167c974673d19730022e9c589b9c0b8216e88 (patch) | |
tree | 9f078e2c06cab0a5b693ae380bd36280a2a8af71 | |
parent | d98998a26b3ea1d520564f928d7a1f1fc6986415 (diff) | |
download | cython-b07167c974673d19730022e9c589b9c0b8216e88.tar.gz |
FROM_PY_FUNCTION: Cast to sdigit after unary minus, not before
The current cast isn't doing anything, because the unary minus implicitly
upcasts to int again, resulting in warnings about potentially value altering
conversions on 32 bit systems.
Fixes issue #877.
-rw-r--r-- | Cython/Utility/TypeConversion.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c index f84dea68d..c601b540e 100644 --- a/Cython/Utility/TypeConversion.c +++ b/Cython/Utility/TypeConversion.c @@ -667,7 +667,7 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) { const digit* digits = ((PyLongObject*)x)->ob_digit; switch (Py_SIZE(x)) { case 0: return ({{TYPE}}) 0; - case -1: __PYX_VERIFY_RETURN_INT({{TYPE}}, sdigit, -(sdigit) digits[0]) + case -1: __PYX_VERIFY_RETURN_INT({{TYPE}}, sdigit, (sdigit) -digits[0]) case 1: __PYX_VERIFY_RETURN_INT({{TYPE}}, digit, +digits[0]) {{for _size in (2, 3, 4)}} {{for _case in (-_size, _size)}} |