diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-12 09:52:48 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-12 09:52:48 +0000 |
commit | c13cd729bfdb5f5eb44ec681db4fea85f029a31f (patch) | |
tree | 8309aac94863ebd96460329ba5839aa7acbebbfc /insns.def | |
parent | 4c289d8d104fc3cd73858b4dc2bdf13c62f50377 (diff) | |
download | ruby-c13cd729bfdb5f5eb44ec681db4fea85f029a31f.tar.gz |
* range.c (range_max): use FIX2LONG instead of FIX2INT to avoid
RangeError by ((-0x80000001)...(-0x80000001)).max on LP64.
* insns.def (opt_plus): use FIX2LONG instead of FIX2INT to avoid
RangeError by 0x3fffffffffffffff+1 on LP64.
* insns.def (opt_succ): don't use 0x80000000 which assumes 32bit VALUE.
use FIX2LONG instead of FIX2INT.
[ruby-dev:31190]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r-- | insns.def | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1677,8 +1677,8 @@ opt_plus val = (recv + (obj & (~1))); if ((~(recv ^ obj) & (recv ^ val)) & ((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) { - val = rb_big_plus(rb_int2big(FIX2INT(recv)), - rb_int2big(FIX2INT(obj))); + val = rb_big_plus(rb_int2big(FIX2LONG(recv)), + rb_int2big(FIX2LONG(obj))); } #else long a, b, c; @@ -2304,9 +2304,10 @@ opt_succ const VALUE obj = INT2FIX(1); /* fixnum + INT2FIX(1) */ val = (recv + (obj & (~1))); - if ((~(recv ^ obj) & (recv ^ val)) & 0x80000000) { - val = rb_big_plus(rb_int2big(FIX2INT(recv)), - rb_int2big(FIX2INT(obj))); + if ((~(recv ^ obj) & (recv ^ val)) & + ((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) { + val = rb_big_plus(rb_int2big(FIX2LONG(recv)), + rb_int2big(FIX2LONG(obj))); } } else { |