[Issue 5871] schwartzSort with stable SwapStrategy errors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 22 23:48:34 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5871


kennytm at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |kennytm at gmail.com


--- Comment #2 from kennytm at 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: -------


More information about the Digitalmars-d-bugs mailing list