Commit b07167c9 authored by Nikolaus Rath's avatar Nikolaus Rath Committed by Stefan Behnel

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.
parent d98998a2
......@@ -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)}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment