/////////////// Common.proto ///////////////
-static int __Pyx_check_twos_complement() {
+static int __Pyx_check_twos_complement(void) {
if (-1 != ~0) {
PyErr_SetString(PyExc_RuntimeError, "Two's complement required for overflow checks.");
return 1;
/////////////// SizeCheck.proto ///////////////
-static int __Pyx_check_sane_{{NAME}}() {
+static int __Pyx_check_sane_{{NAME}}(void) {
if (sizeof({{TYPE}}) <= sizeof(int) ||
sizeof({{TYPE}}) == sizeof(long) ||
sizeof({{TYPE}}) == sizeof(long long)) {
#if {{SIGNED}}
(b < 0) |
#endif
- (b > (8 * sizeof({{TYPE}}))) | (a > (__PYX_MAX({{TYPE}}) >> b));
+ (b > ({{TYPE}}) (8 * sizeof({{TYPE}}))) | (a > (__PYX_MAX({{TYPE}}) >> b));
return a << b;
}
#define __Pyx_lshift_const_{{NAME}}_checking_overflow __Pyx_lshift_{{NAME}}_checking_overflow
cdef bint is_signed_ = ((<INT>-1) < 0)
cdef INT max_value_ = <INT>(two ** (size_in_bits - is_signed_) - 1)
cdef INT min_value_ = ~max_value_
-cdef INT half_ = max_value_ // 2
+cdef INT half_ = max_value_ // <INT>2
# Python visible.
is_signed = is_signed_
from libc.math cimport sqrt
cpdef check(func, op, a, b):
- cdef INT res, op_res
+ cdef INT res = 0, op_res = 0
cdef bint func_overflow = False
cdef bint assign_overflow = False
try:
if not func_overflow:
assert res == op_res, "Inconsistant values: %s(%s, %s) == %s != %s" % (func, a, b, res, op_res)
-medium_values = (max_value_ / 2, max_value_ / 3, min_value_ / 2, <INT>sqrt(max_value_) - 1, <INT>sqrt(max_value_) + 1)
+medium_values = (max_value_ / 2, max_value_ / 3, min_value_ / 2, <INT>sqrt(max_value_) - <INT>1, <INT>sqrt(max_value_) + 1)
def run_test(func, op):
cdef INT offset, b
check(func, op, 300, 200)
check(func, op, min_value_, min_value_)
for offset in range(5):
- check(func, op, max_value_ - 1, offset)
- check(func, op, min_value_ + 1, offset)
+ check(func, op, max_value_ - <INT>1, offset)
+ check(func, op, min_value_ + <INT>1, offset)
if is_signed_:
check(func, op, max_value_ - 1, 2 - offset)
check(func, op, min_value_ + 1, 2 - offset)