lshift must not assume sizeof(long) >= sizeof(mrb_int)

This commit is contained in:
Yukihiro Matsumoto
2012-10-19 01:50:40 +09:00
parent 19cd9c6e2e
commit ac3b1c4c5a
+1 -2
View File
@@ -949,8 +949,7 @@ fix_xor(mrb_state *mrb, mrb_value x)
static mrb_value
lshift(mrb_state *mrb, mrb_int val, unsigned long width)
{
if (width > (sizeof(mrb_int)*CHAR_BIT-1)
|| ((unsigned long)abs(val))>>(sizeof(mrb_int)*CHAR_BIT-1-width) > 0) {
if (width > (sizeof(mrb_int)*CHAR_BIT-1)) {
mrb_raise(mrb, E_RANGE_ERROR, "width(%d) > (%d:sizeof(mrb_int)*CHAR_BIT-1)", width,
sizeof(mrb_int)*CHAR_BIT-1);
}