commit 26e91f1858aa054c28b521d86065966df4ba7099
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed May 24 17:41:34 2017 +0100
Use CHAR_BIT instead of assuming 8 bits
* src/c++11/random.cc (random_device::_M_getentropy): Use __CHAR_BIT__
instead of fixed number of bits.
@@ -187,8 +187,9 @@ namespace std _GLIBCXX_VISIBILITY(default)
if (ent < 0)
return 0.0;
- if (static_cast<unsigned>(ent) > sizeof(result_type) * 8)
- return static_cast<double>(sizeof(result_type) * 8);
+ const int max = sizeof(result_type) * __CHAR_BIT__;
+ if (ent > max)
+ ent = max;
return static_cast<double>(ent);
#else