From d42afbfb1fdfad94e5d995de55f06ac0b87007ec Mon Sep 17 00:00:00 2001 From: Stefan Behnel <stefan_ml@behnel.de> Date: Fri, 22 Sep 2017 22:51:05 +0200 Subject: [PATCH] Remove all (incorrect) casts in abs(long long). --- Cython/Utility/Builtins.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cython/Utility/Builtins.c b/Cython/Utility/Builtins.c index 61ad4c378..c365bc1c1 100644 --- a/Cython/Utility/Builtins.c +++ b/Cython/Utility/Builtins.c @@ -235,20 +235,20 @@ static PyObject* __Pyx_Intern(PyObject* s) { static CYTHON_INLINE PY_LONG_LONG __Pyx_abs_longlong(PY_LONG_LONG x) { #if defined (__cplusplus) && __cplusplus >= 201103L - return (unsigned PY_LONG_LONG) std::abs(x); + return std::abs(x); #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - return (unsigned PY_LONG_LONG) llabs(x); + return llabs(x); #elif defined (_MSC_VER) // abs() is defined for long, but 64-bits type on MSVC is long long. // Use MS-specific _abs64() instead, which returns the original (negative) value for abs(-MAX-1) return _abs64(x); #elif defined (__GNUC__) // gcc or clang on 64 bit windows. - return (unsigned PY_LONG_LONG) __builtin_llabs(x); + return __builtin_llabs(x); #else if (sizeof(PY_LONG_LONG) <= sizeof(Py_ssize_t)) - return (unsigned PY_LONG_LONG) __Pyx_sst_abs(x); - return (x<0) ? (unsigned PY_LONG_LONG)-x : (unsigned PY_LONG_LONG)x; + return __Pyx_sst_abs(x); + return (x<0) ? x*(PY_LONG_LONG)-1 : x; #endif } -- 2.30.9