Skip to content
Snippets Groups Projects
Commit 07e03761 authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

libstdc++: Fix infinite loop in std::binomial_distribution [PR114359]

The multiplication (4 * _M_t * __1p) can wraparound to zero if _M_t is
unsigned and 4 * _M_t wraps to zero. The third operand has type double,
so do the second multiplication first, so that we aren't multiplying
integers.

libstdc++-v3/ChangeLog:

	PR libstdc++/114359
	* include/bits/random.tcc (binomial_distribution::param_type):
	Ensure arithmetic is done as type double.
	* testsuite/26_numerics/random/binomial_distribution/114359.cc: New test.
parent c608b57f
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment