Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined behavior: Upper bound of zero #29

Open
48656c6c6f opened this issue Jan 19, 2020 · 1 comment
Open

Undefined behavior: Upper bound of zero #29

48656c6c6f opened this issue Jan 19, 2020 · 1 comment

Comments

@48656c6c6f
Copy link

When a function such as pcg_setseq_64_xsh_rr_32_boundedrand_r is called with a bound of 0 and bound is the denominator of a modulus operation, the result is undefined behavior -- possibly a division by zero error.

Such functions should check for and return zero in such cases to avoid undefined behavior.

@lemire
Copy link

lemire commented Jan 19, 2020

As an aside, these functions can be optimized to require just one division instead of two. @imneme knows how!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants