ruby-changes:49514
From: naruse <ko1@a...>
Date: Sat, 6 Jan 2018 05:40:15 +0900 (JST)
Subject: [ruby-changes:49514] naruse:r61629 (ruby_2_5): merge revision(s) 61517: [Backport #14259]
naruse 2018-01-06 05:40:12 +0900 (Sat, 06 Jan 2018) New Revision: 61629 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61629 Log: merge revision(s) 61517: [Backport #14259] numeric.c: Fix Integer#pow with a large Fixnum modulo * numeric.c: Fix Integer#pow with a large Fixnum modulo [Bug #14259] [ruby-core:84562] * test/ruby/test_numeric.rb: add assertions for reproducing this bug. Modified directories: branches/ruby_2_5/ Modified files: branches/ruby_2_5/bignum.c branches/ruby_2_5/test/ruby/test_numeric.rb branches/ruby_2_5/version.h Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 61628) +++ ruby_2_5/version.h (revision 61629) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.0" #define RUBY_RELEASE_DATE "2018-01-06" -#define RUBY_PATCHLEVEL 7 +#define RUBY_PATCHLEVEL 8 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 1 Index: ruby_2_5/bignum.c =================================================================== --- ruby_2_5/bignum.c (revision 61628) +++ ruby_2_5/bignum.c (revision 61629) @@ -7016,7 +7016,9 @@ int_pow_tmp2(VALUE x, VALUE y, long mm, https://github.com/ruby/ruby/blob/trunk/ruby_2_5/bignum.c#L7016 xx = MUL_MODULO(xx, xx, m); } -#ifndef DLONG +#ifdef DLONG + tmp = tmp2; +#else tmp = FIX2LONG(tmp2); #endif if (nega_flg && tmp) { Index: ruby_2_5/test/ruby/test_numeric.rb =================================================================== --- ruby_2_5/test/ruby/test_numeric.rb (revision 61628) +++ ruby_2_5/test/ruby/test_numeric.rb (revision 61629) @@ -400,6 +400,11 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_numeric.rb#L400 2120078484650058507891187874713297895455. pow(5478118174010360425845660566650432540723, 5263488859030795548286226023720904036518)) + + assert_equal(12, 12.pow(1, 10000000000), '[Bug #14259]') + assert_equal(12, 12.pow(1, 10000000001), '[Bug #14259]') + assert_equal(12, 12.pow(1, 10000000002), '[Bug #14259]') + assert_equal(17298641040, 12.pow(72387894339363242, 243682743764), '[Bug #14259]') end end Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 61628) +++ ruby_2_5 (revision 61629) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r61517 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/