summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c7
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0ee7f87ed0..1893a81906 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Mar 27 01:19:50 2009 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (rb_cmpint): FIX2INT may fail on LP64 platforms.
+
Fri Mar 13 21:11:51 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/sdbm/_sdbm.c: should include "ruby/defines.h" as well for
diff --git a/bignum.c b/bignum.c
index 35db091454..5a608774e7 100644
--- a/bignum.c
+++ b/bignum.c
@@ -56,7 +56,12 @@ rb_cmpint(VALUE val, VALUE a, VALUE b)
if (NIL_P(val)) {
rb_cmperr(a, b);
}
- if (FIXNUM_P(val)) return FIX2INT(val);
+ if (FIXNUM_P(val)) {
+ long l = FIX2LONG(val);
+ if (l > 0) return 1;
+ if (l < 0) return -1;
+ return 0;
+ }
if (TYPE(val) == T_BIGNUM) {
if (BIGZEROP(val)) return 0;
if (RBIGNUM_SIGN(val)) return 1;