https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112015-12-11T08:26:15ZRuby Issue Tracking SystemRuby master - Bug #11804: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生するhttps://bugs.ruby-lang.org/issues/11804?journal_id=554602015-12-11T08:26:15Zyui-knk (Kaneko Yuichiro)
<ul><li><strong>Subject</strong> changed from <i>52693 以降、caseでInfinityを使用するとFloatDomainErrorが発生する</i> to <i>52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生する</i></li></ul> Ruby master - Bug #11804: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生するhttps://bugs.ruby-lang.org/issues/11804?journal_id=554622015-12-11T09:05:15Znormalperson (Eric Wong)normalperson@yhbt.net
<ul><li><strong>Backport</strong> changed from <i>2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN</i> to <i>2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED</i></li></ul><p>Not a new bug, actually; just easier to find since r52931<br>
(Sorry I don't know Japanese, but was able to understand the Ruby at least).<br>
This will need to be backported.</p>
<pre><code>inf = 1.0/0.0
result = case inf
when 1 then 1
when 0 then 0
else
inf.to_i rescue nil
end
p result
diff --git a/insns.def b/insns.def
index 3c185bd..df65aa8 100644
--- a/insns.def
+++ b/insns.def
@@ -1262,7 +1262,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);
}
}
</code></pre> Ruby master - Bug #11804: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生するhttps://bugs.ruby-lang.org/issues/11804?journal_id=554632015-12-11T09:15:29ZAnonymous
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset r53039.</p>
<hr>
<p>insns.def (opt_case_dispatch): avoid converting Infinity</p>
<p>Infinity cannot be written as an optimizable literal,<br>
so it can never match a key in a CDHASH.<br>
Avoid converting it to prevent FloatDomainError.</p>
<ul>
<li>insns.def (opt_case_dispatch): avoid converting Infinity</li>
<li>test/ruby/test_optimization.rb (test_opt_case_dispatch_inf): new<br>
<a href="/issues/11804">[ruby-dev:49423]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生する (Closed)" href="https://bugs.ruby-lang.org/issues/11804">#11804</a>]</li>
</ul> Ruby master - Bug #11804: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生するhttps://bugs.ruby-lang.org/issues/11804?journal_id=554652015-12-11T13:53:02Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED</i> to <i>2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE</i></li></ul><p>Backported into <code>ruby_2_2</code> branch at r53040.</p> Ruby master - Bug #11804: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生するhttps://bugs.ruby-lang.org/issues/11804?journal_id=554662015-12-11T16:03:08Zyui-knk (Kaneko Yuichiro)
<ul></ul><p>Thanks for your patch (Eric) :)</p> Ruby master - Bug #11804: 52931 以降、caseでInfinityを使用するとFloatDomainErrorが発生するhttps://bugs.ruby-lang.org/issues/11804?journal_id=555882015-12-16T07:11:58Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Backport</strong> changed from <i>2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE</i> to <i>2.0.0: REQUIRED, 2.1: DONE, 2.2: DONE</i></li></ul><p>ruby_2_1 r53147 merged revision(s) 53039.</p>