Bug 8495 – A problem with std.algorithm.remove on array of fixed size array
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-08-02T12:14:00Z
Last change time
2015-12-02T16:13:07Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-08-02T12:14:16Z
This program works:
import std.stdio: writeln;
import std.algorithm: remove, countUntil;
void main() {
alias int[] P;
P[] data = [[1, 2], [3, 4], [5, 6]];
P x = [3, 4];
data.remove(data.countUntil(x));
data.length--;
writeln(data);
}
Output:
[[1, 2], [5, 6]]
But this fails compiling:
//import std.stdio: writeln;
import std.algorithm: remove, countUntil;
void main() {
alias int[2] P;
P[] data = [[1, 2], [3, 4], [5, 6]];
P x = [3, 4];
data.remove(data.countUntil(x));
data.length--;
// writeln(data);
}
DMD 2.060beta gives:
[email protected](1342): Assertion failure
----------------
0x0040E284 in char[][] core.sys.windows.stacktrace.StackTrace.trace()
0x0040E10F in core.sys.windows.stacktrace.StackTrace core.sys.windows.stacktrace.StackTrace.__ctor()
0x00409A2B in onAssertError
0x0040261F in int[2][] std.algorithm.moveAll!(int[2][], int[2][]).moveAll(int[2][], int[2][]) at ...\dmd2\src\phobos\std\algorithm.d(1595)
0x0040245A in int[2][] std.algorithm.__T6removeVE3std9algorithm12SwapStrategy2TAG2iTiZ.remove(int[2][], int) at ...\dmd2\src\phobos\std\algorithm.d(6334)
0x004020F8 in _Dmain at C:\leonardo\d_bugs\bug.d(8)
0x00402B70 in extern (C) int rt.dmain2.main(int, char**).void runMain()
0x00402BAA in extern (C) int rt.dmain2.main(int, char**).void runAll()
0x004027CC in main
0x00414E7D in mainCRTStartup
0x7697D309 in BaseThreadInitThunk
0x76FB1603 in RtlInitializeExceptionChain
0x76FB15D6 in RtlInitializeExceptionChain
Comment #1 by lt.infiltrator — 2015-12-02T16:13:07Z