Skip to content

Commit

Permalink
Fix PR#24267. use numeric_limits::max instead of ~0 for 'all ones', s…
Browse files Browse the repository at this point in the history
…ince that might give wrong answers on a 1's complement machine.

llvm-svn: 243674
  • Loading branch information
mclow committed Jul 30, 2015
1 parent e96b851 commit a6438ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libcxx/include/algorithm
Expand Up @@ -3037,7 +3037,7 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
if (_Rp == 0)
return static_cast<result_type>(_Eng(__g, _Dt)());
size_t __w = _Dt - __clz(_Rp) - 1;
if ((_Rp & (_UIntType(~0) >> (_Dt - __w))) != 0)
if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
++__w;
_Eng __e(__g, __w);
_UIntType __u;
Expand Down

0 comments on commit a6438ca

Please sign in to comment.