Fix bug in random.

Test: ./run_test.py --bitness 32
Test: ./run_test.py --bitness 64
Test: ./run_test.py --bitness 64 --host
Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=994957
Bug: http://b/139690488
Change-Id: I71708114d7fc8ed90c30b4d32b01d3f3aef7600b
(cherry picked from commit a1d1caa3d831030ce802ed335a9743180911d553)
This commit is contained in:
Dan Albert
2019-09-10 21:52:53 -07:00
parent 44a8861f2c
commit 819e8133bd
3 changed files with 103 additions and 21 deletions

View File

@@ -29,6 +29,20 @@ sqr(T x)
return x * x;
}
struct Eng : std::mt19937 {
using Base = std::mt19937;
using Base::Base;
};
void test_small_inputs() {
Eng engine;
std::geometric_distribution<std::int16_t> distribution(5.45361e-311);
for (auto i=0; i < 1000; ++i) {
volatile auto res = distribution(engine);
((void)res);
}
}
void
test1()
{
@@ -295,4 +309,5 @@ int main()
test4();
test5();
test6();
test_small_inputs();
}