mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
4c289d8d10
commit
c13cd729bf
3 changed files with 19 additions and 6 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
Thu Jul 12 18:42:18 2007 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* 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]
|
||||||
|
|
||||||
Thu Jul 12 17:03:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Jul 12 17:03:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* struct.c (rb_struct_init_copy): disallow changing the size.
|
* struct.c (rb_struct_init_copy): disallow changing the size.
|
||||||
|
|
11
insns.def
11
insns.def
|
@ -1677,8 +1677,8 @@ opt_plus
|
||||||
val = (recv + (obj & (~1)));
|
val = (recv + (obj & (~1)));
|
||||||
if ((~(recv ^ obj) & (recv ^ val)) &
|
if ((~(recv ^ obj) & (recv ^ val)) &
|
||||||
((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) {
|
((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) {
|
||||||
val = rb_big_plus(rb_int2big(FIX2INT(recv)),
|
val = rb_big_plus(rb_int2big(FIX2LONG(recv)),
|
||||||
rb_int2big(FIX2INT(obj)));
|
rb_int2big(FIX2LONG(obj)));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
long a, b, c;
|
long a, b, c;
|
||||||
|
@ -2304,9 +2304,10 @@ opt_succ
|
||||||
const VALUE obj = INT2FIX(1);
|
const VALUE obj = INT2FIX(1);
|
||||||
/* fixnum + INT2FIX(1) */
|
/* fixnum + INT2FIX(1) */
|
||||||
val = (recv + (obj & (~1)));
|
val = (recv + (obj & (~1)));
|
||||||
if ((~(recv ^ obj) & (recv ^ val)) & 0x80000000) {
|
if ((~(recv ^ obj) & (recv ^ val)) &
|
||||||
val = rb_big_plus(rb_int2big(FIX2INT(recv)),
|
((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) {
|
||||||
rb_int2big(FIX2INT(obj)));
|
val = rb_big_plus(rb_int2big(FIX2LONG(recv)),
|
||||||
|
rb_int2big(FIX2LONG(obj)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
2
range.c
2
range.c
|
@ -503,7 +503,7 @@ range_max(VALUE range)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
if (EXCL(range)) {
|
if (EXCL(range)) {
|
||||||
if (FIXNUM_P(e)) {
|
if (FIXNUM_P(e)) {
|
||||||
return INT2NUM(FIX2INT(e) - 1);
|
return LONG2NUM(FIX2LONG(e) - 1);
|
||||||
}
|
}
|
||||||
return rb_funcall(e, '-', 1, INT2FIX(1));
|
return rb_funcall(e, '-', 1, INT2FIX(1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue