Skip to content

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

Open
@viafanasyev

Description

@viafanasyev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions