The following the loops will run even though they shouldn't:
cdef unsigned int k = ((<unsigned int>-1)>>1) + 1 # Very large number
cdef int i = -1
cdef unsigned int j
for j from k <= j < i by 2:
print j
for j in range(k, i, 2):
print j
This is because the start value is larger than INT_MAX and C will default to an unsigned comparison, where the -1 representation appears to be UINT_MAX.
The following the loops will run even though they shouldn't:
This is because the start value is larger than INT_MAX and C will default to an unsigned comparison, where the -1 representation appears to be UINT_MAX.
Migrated from http://trac.cython.org/ticket/849