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

ruby-changes:47900

From: naruse <ko1@a...>
Date: Mon, 25 Sep 2017 17:19:14 +0900 (JST)
Subject: [ruby-changes:47900] naruse:r60019 (trunk): Fix overflow detection for LLP64 arch [Bug #13748]

naruse	2017-09-25 17:19:10 +0900 (Mon, 25 Sep 2017)

  New Revision: 60019

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60019

  Log:
    Fix overflow detection for LLP64 arch [Bug #13748]
    
    FIXNUMs are expected to fit into a long type, but the test is about a
    VALUE type. Since long is < than VALUE on LLP64, the overflow is not
    detected. As a result "2**31" evaluates to "-2147483648" on Windows with
    gcc-7.1.0.
    patched by Lars Kanis <lars@g...>

  Modified files:
    trunk/internal.h
Index: internal.h
===================================================================
--- internal.h	(revision 60018)
+++ internal.h	(revision 60019)
@@ -115,7 +115,7 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L115
 /* __builtin_mul_overflow_p can take bitfield */
 /* and GCC permits bitfields for integers other than int */
 #define MUL_OVERFLOW_FIXNUM_P(a, b) ({ \
-    struct { SIGNED_VALUE fixnum : SIZEOF_VALUE * CHAR_BIT - 1; } c; \
+    struct { long fixnum : SIZEOF_LONG * CHAR_BIT - 1; } c; \
     __builtin_mul_overflow_p((a), (b), c.fixnum); \
 })
 #else

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

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