digitalmars.D.bugs - [Issue 14340] New: AssertError in std.algorithm.sorting: unstable
- via Digitalmars-d-bugs (37/37) Mar 25 2015 https://issues.dlang.org/show_bug.cgi?id=14340
https://issues.dlang.org/show_bug.cgi?id=14340 Issue ID: 14340 Summary: AssertError in std.algorithm.sorting: unstable sort fails to sort an array with a custom predicate Product: D Version: D2 Hardware: All OS: Windows Status: NEW Severity: major Priority: P1 Component: Phobos Assignee: nobody puremagic.com Reporter: gassa mail.ru Created attachment 1497 --> https://issues.dlang.org/attachment.cgi?id=1497&action=edit example code This example code, compiled with -debug, triggers an AssertError. ----- import std.algorithm, std.conv, std.range, std.stdio; void main () { auto arr = [7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1, 2, 2, 8, 5, 8, 8]; arr.sort !((x, y) => arr.count (x) > arr.count (y) || (arr.count (x) == arr.count (y) && x < y)) .map !(to !(string)) .join (" ") .writeln; // prints 1 1 1 1 1 3 3 3 3 3 5 5 5 5 8 8 8 2 2 0 7 7 // should 1 1 1 1 1 3 3 3 3 3 5 5 5 5 8 8 8 2 2 7 7 0 } ----- Reproducible on Win64 with DMD 2.066 or 2.067, -m32 or -m64. Without -debug, it produces wrong output with -m32 and crashes with -m64. The D.learn discussion resulting in this example: http://forum.dlang.org/thread/fqbojlyocmsovrpzilhu forum.dlang.org --
Mar 25 2015