digitalmars.D.bugs - [Issue 5871] New: schwartzSort with stable SwapStrategy errors
- d-bugmail puremagic.com (29/29) Apr 22 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5871
- d-bugmail puremagic.com (14/14) Apr 22 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5871
- d-bugmail puremagic.com (45/45) Apr 22 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5871
- d-bugmail puremagic.com (7/9) Apr 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5871
http://d.puremagic.com/issues/show_bug.cgi?id=5871 Summary: schwartzSort with stable SwapStrategy errors Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2011-04-22 18:47:13 PDT --- This D2 program: import std.algorithm; void main() { char[] s = "test".dup; int[] indexes = [0, 1, 2, 3]; schwartzSort!((int i){ return s.count(s[i]); }, "b < a", SwapStrategy.stable)(indexes); } With DMD 2.052 gives the error: ...\dmd\src\phobos\std\algorithm.d(6121): Error: undefined identifier __dollar Once "fixed" that line replacing $ with r.length more successive similar errors appear. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 22 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5871 --- Comment #1 from bearophile_hugs eml.cc 2011-04-22 19:36:53 PDT --- This compiles, s is a int[] instead of char[]: import std.algorithm, std.stdio; void main() { int[] s = [10, 20, 30, 10, 20, 10]; int[] indexes = [0, 1, 2, 3, 4, 5]; schwartzSort!((int i){ return s.count(s[i]); }, "b < a", SwapStrategy.stable)(indexes); writeln(indexes); // output: [0, 1, 2, 3, 4, 5] } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 22 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5871 kennytm gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid CC| |kennytm gmail.com --- Comment #2 from kennytm gmail.com 2011-04-22 23:44:54 PDT --- 1. Your 2nd program does not compile for me, both the 2.052 and the git master version. /usr/include/phobos/std/algorithm.d(5841): Error: undefined identifier __dollar 2. After changing 3 '$' to '.length' both program compiles successfully. diff --git a/std/algorithm.d b/std/algorithm.d index fd5df21..376c906 100644 --- a/std/algorithm.d +++ b/std/algorithm.d -5838,7 +5838,7 Range partition(alias predicate, const middle = r.length / 2; alias .partition!(pred, ss, Range) recurse; auto lower = recurse(r[0 .. middle]); - auto upper = recurse(r[middle .. $]); + auto upper = recurse(r[middle .. r.length]); bringToFront(lower, r[middle .. r.length - upper.length]); return r[r.length - lower.length - upper.length .. r.length]; } -6385,11 +6385,11 void sortImpl(alias less, SwapStrategy ss, Range)(Range r) // find the last occurrence of the pivot bool pred2(Elem a) { return less(pivot, a); } //auto lastPivotPos = find!(pred2)(pivotsRight[1 .. $]).ptr; - auto pivotRunLen = find!(pred2)(pivotSpan[1 .. $]).length; + auto pivotRunLen = find!(pred2)(pivotSpan[1 .. pivotSpan.length]).length; pivotSpan = pivotSpan[0 .. pivotRunLen + 1]; // now rotate firstPivotPos..lastPivotPos to the front bringToFront(r, pivotSpan); - r = r[pivotSpan.length .. $]; + r = r[pivotSpan.length .. r.length]; } else { 3. Even with this patch (I don't know if it's correct), the 2nd program won't work correctly because of bug 4584 and bug 3638 (they're the same?). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 22 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5871 --- Comment #3 from bearophile_hugs eml.cc 2011-04-23 03:58:37 PDT --- (In reply to comment #2)1. Your 2nd program does not compile for me, both the 2.052 and the git master version.You are right. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 23 2011