From 454f028632f72495427874a8a0ff1905a318a6bf Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 4 Jul 2016 04:09:51 +0000 Subject: [PATCH] * random.c (random_ulong_limited): avoid left shift count >= width of type on 32bit environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ random.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5355a7943d..657b353d48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jul 4 13:08:48 2016 NARUSE, Yui + + * random.c (random_ulong_limited): avoid left shift count >= width of + type on 32bit environment. + Sun Jul 3 18:51:42 2016 Martin Duerst * test/ruby/enc/test_case_comprehensive.rb, test_regex_casefold.rb, diff --git a/random.c b/random.c index 4ffebf07f9..bc6474f864 100644 --- a/random.c +++ b/random.c @@ -992,9 +992,7 @@ random_ulong_limited(VALUE obj, rb_random_t *rnd, unsigned long limit) const int n = w > 32 ? sizeof(unsigned long) : sizeof(uint32_t); const unsigned long mask = ~(~0UL << w); const unsigned long full = -#if SIZEOF_LONG == 4 (size_t)n >= sizeof(unsigned long) ? ~0UL : -#endif ~(~0UL << n * CHAR_BIT); unsigned long val, bits = 0, rest = 0; do {