imneme/pcg-c

Undefined behavior: Upper bound of zero

48656c6c6f opened this issue · 1 comments

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.

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