[ruby-core:80376] [Ruby trunk Bug#13053] Array#select! can resize to negative size

From: nagachika00@...
Date: 2017-03-27 12:27:04 UTC
List: ruby-core #80376
Issue #13053 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE

ruby_2_3 r58149 merged revision(s) 57121.

----------------------------------------
Bug #13053: Array#select! can resize to negative size
https://bugs.ruby-lang.org/issues/13053#change-63857

* Author: rhenium (Kazuki Yamaguchi)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE
----------------------------------------
Since Ruby 2.3 ([Feature #10714]), the following code cause the Array to be nagative number size.

~~~ruby
ary = [1,2,3,4,5]
ary.select! { |i| ary.clear if i==5; false }
p ary #=> []
p ary.size #=> -5
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next