digitalmars.D.bugs - [Issue 6956] New: std.algorithm.remove problem with SwapStrategy.unstable
- d-bugmail puremagic.com (39/39) Nov 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6956
- d-bugmail puremagic.com (12/12) Apr 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6956
- d-bugmail puremagic.com (20/20) May 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6956
- d-bugmail puremagic.com (8/9) May 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6956
http://d.puremagic.com/issues/show_bug.cgi?id=6956
Summary: std.algorithm.remove problem with
SwapStrategy.unstable
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
This is a spin off of bug 6849. Problem partially found by Steven
Schveighoffer.
import std.stdio, std.algorithm;
void main() {
int[] data1 = [10, 20, 30, 40];
writeln(remove(data1, 1));
writeln(data1);
int[] data2 = [10, 20, 30, 40];
writeln(remove!(SwapStrategy.unstable)(data2, 1));
writeln(data2);
}
Output, DMD 2.057head:
[10, 30, 40]
[10, 30, 40, 40]
[40, 20, 30]
[40, 20, 30, 40]
So with SwapStrategy.unstable it seems index 0 was removed, not index 1.
Expected output:
[10, 30, 40]
[10, 30, 40, 40]
[10, 40, 30]
[10, 40, 30, 40]
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6956
SomeDude <lovelydear mailmetrash.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |lovelydear mailmetrash.com
Resolution| |DUPLICATE
PDT ---
*** This issue has been marked as a duplicate of issue 5224 ***
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6956
Andrej Mitrovic <andrej.mitrovich gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |andrej.mitrovich gmail.com
08:37:54 PDT ---
I don't know if a bug is opened about this but it seems relevant:
import std.algorithm;
import std.stdio;
void main()
{
int[] a = [1, 2, 3];
a = a.remove(3);
writeln(a);
}
writes [1, 2]
This should throw since index 3 is out of bounds.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6956I don't know if a bug is opened about this but it seems relevant:This is a closed (because it's a duplicate) bug, so I suggest you to copy that stuff elsewhere. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 25 2012









d-bugmail puremagic.com 