[前][次][番号順一覧][スレッド一覧]

ruby-changes:65015

From: Yusuke <ko1@a...>
Date: Sat, 23 Jan 2021 16:08:45 +0900 (JST)
Subject: [ruby-changes:65015] dd65aa95f9 (master): bignum.c: Make sure the argument of LONG2FIX is long

https://git.ruby-lang.org/ruby.git/commit/?id=dd65aa95f9

From dd65aa95f9bf017674b9f11c9e5824cd0fa22735 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sat, 23 Jan 2021 16:05:33 +0900
Subject: bignum.c: Make sure the argument of LONG2FIX is long

... because BDIGIT_DBL may be long long. POSFIXABLE and NEGFIXABLE
ensures that the value is representable as long, but it failed to build
on emscripten with -Werror -Wshorten-64-to-32.
---
 bignum.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bignum.c b/bignum.c
index 192e384..b4de57d 100644
--- a/bignum.c
+++ b/bignum.c
@@ -3689,10 +3689,10 @@ rb_integer_unpack(const void *words, size_t numwords, size_t wordsize, size_t na https://github.com/ruby/ruby/blob/trunk/bignum.c#L3689
         if (u == 0)
             return LONG2FIX(0);
 	if (0 < sign && POSFIXABLE(u))
-            return LONG2FIX(u);
+            return LONG2FIX((long)u);
 	if (sign < 0 && BDIGIT_MSB(fixbuf[1]) == 0 &&
                 NEGFIXABLE(-(BDIGIT_DBL_SIGNED)u))
-            return LONG2FIX(-(BDIGIT_DBL_SIGNED)u);
+            return LONG2FIX((long)-(BDIGIT_DBL_SIGNED)u);
         val = bignew((long)num_bdigits, 0 <= sign);
         MEMCPY(BDIGITS(val), fixbuf, BDIGIT, num_bdigits);
     }
@@ -4487,14 +4487,14 @@ rb_ll2big(LONG_LONG n) https://github.com/ruby/ruby/blob/trunk/bignum.c#L4487
 VALUE
 rb_ull2inum(unsigned LONG_LONG n)
 {
-    if (POSFIXABLE(n)) return LONG2FIX(n);
+    if (POSFIXABLE(n)) return LONG2FIX((long)n);
     return rb_ull2big(n);
 }
 
 VALUE
 rb_ll2inum(LONG_LONG n)
 {
-    if (FIXABLE(n)) return LONG2FIX(n);
+    if (FIXABLE(n)) return LONG2FIX((long)n);
     return rb_ll2big(n);
 }
 
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]