aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-15 03:03:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-15 03:03:45 +0000
commit0a3fb9af9518e91d68b9b77ca7e69a31827a491f (patch)
treeaa0bee9c7edecb776390c5b3ca00e21fc4b5292c
parent4e2d5e645af563b3a2fbaea7ecdb2cb1150cc834 (diff)
downloadruby-0a3fb9af9518e91d68b9b77ca7e69a31827a491f.tar.gz
random.c: suppress a warning
* random.c (random_ulong_limited): suppress a shift count warning when unsigned long is 32bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--random.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/random.c b/random.c
index 3be22a4ec0..1093a103c1 100644
--- a/random.c
+++ b/random.c
@@ -991,7 +991,11 @@ random_ulong_limited(VALUE obj, rb_random_t *rnd, unsigned long limit)
const int w = sizeof(limit) * CHAR_BIT - nlz_long(limit);
const int n = w > 32 ? sizeof(unsigned long) : sizeof(uint32_t);
const unsigned long mask = ~(~0UL << w);
- const unsigned long full = ~(~0UL << n * CHAR_BIT);
+ 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 {
if (mask & ~rest) {