aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-01 17:04:04 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-01 17:04:04 +0000
commita3918d3936b4a19c842e4218e7042d3dce157395 (patch)
tree5b953518abd1ced3d710019b05857f0473728359 /numeric.c
parent278063283b2b02c60da7e2acd21490a9c5c80fd8 (diff)
downloadruby-a3918d3936b4a19c842e4218e7042d3dce157395.tar.gz
* numeric.c (rb_fix2str): detect unnormalized Fixnum value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index 770c471672..70982185b3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3267,6 +3267,17 @@ rb_fix2str(VALUE x, int base)
if (base < 2 || 36 < base) {
rb_raise(rb_eArgError, "invalid radix %d", base);
}
+#if SIZEOF_LONG < SIZEOF_VOIDP
+# if SIZEOF_VOIDP == SIZEOF_LONG_LONG
+ if ((val >= 0 && (x & 0xFFFFFFFF00000000ull)) ||
+ (val < 0 && (x & 0xFFFFFFFF00000000ull) != 0xFFFFFFFF00000000ull)) {
+ rb_bug("Unnormalized Fixnum value %p", x);
+ }
+# elif
+ /* should do something like above code, but currently ruby does not know */
+ /* such platforms */
+# endif
+#endif
if (val == 0) {
return rb_usascii_str_new2("0");
}