summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-16 07:11:41 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-16 07:11:41 +0000
commit703a24a9478e83925e4275d126bb54848a72076b (patch)
treec70629a744bc27db836d1b1a40d9d190414b3118
parent2e1523316d1de17fc80257a601aadac6df452fde (diff)
merge revision(s) 53039: [Backport #11804]
* insns.def (opt_case_dispatch): avoid converting Infinity * test/ruby/test_optimization.rb (test_opt_case_dispatch_inf): new [ruby-dev:49423] [Bug #11804]' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@53147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--insns.def2
-rw-r--r--test/ruby/test_optimization.rb11
-rw-r--r--version.h2
4 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ab0e886c24..1e50949eed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Dec 16 16:10:52 2015 Eric Wong <e@80x24.org>
+
+ * insns.def (opt_case_dispatch): avoid converting Infinity
+ * test/ruby/test_optimization.rb (test_opt_case_dispatch_inf): new
+ [ruby-dev:49423] [Bug #11804]'
+
Wed Dec 16 16:07:29 2015 Rei Odaira <Rei.Odaira@gmail.com>
* configure.in: pthread_getattr_np is broken on AIX.
diff --git a/insns.def b/insns.def
index def758a317..1521cb05e9 100644
--- a/insns.def
+++ b/insns.def
@@ -1275,7 +1275,7 @@ opt_case_dispatch
switch(TYPE(key)) {
case T_FLOAT: {
double ival;
- if (modf(RFLOAT_VALUE(key), &ival) == 0.0) {
+ if (modf(RFLOAT_VALUE(key), &ival) == 0.0 && !isinf(ival)) {
key = FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival);
}
}
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index c484dcd0c8..6e22891ddd 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -242,4 +242,15 @@ class TestRubyOptimization < Test::Unit::TestCase
end;
end
end
+
+ def test_opt_case_dispatch_inf
+ inf = 1.0/0.0
+ result = case inf
+ when 1 then 1
+ when 0 then 0
+ else
+ inf.to_i rescue nil
+ end
+ assert_nil result, '[ruby-dev:49423] [Bug #11804]'
+ end
end
diff --git a/version.h b/version.h
index af70d83c76..f1d360d8e2 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.8"
#define RUBY_RELEASE_DATE "2015-12-16"
-#define RUBY_PATCHLEVEL 436
+#define RUBY_PATCHLEVEL 437
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 12