testlib
testlib copied to clipboard
Overflow in rnd.next(long long, long long)
When I try to run this line of code:
rnd.next(INT64_MIN + INT32_MAX - 1LL, INT64_MAX - INT32_MAX + 1LL)
I get the next error:
random_t::next(long long n): n must be positive.
It is caused by the implementation of next(long long, long long): it calls next(to - from + 1), but to - from + 1 is negative because of long long overflow.