testlib icon indicating copy to clipboard operation
testlib copied to clipboard

Overflow in rnd.next(long long, long long)

Open viafanasyev opened this issue 6 years ago • 0 comments

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.

viafanasyev avatar Oct 03 '19 15:10 viafanasyev