Thread overview
[Issue 5853] New: Sorting SysTime: overlapping array copy
Apr 18, 2011
Jesse Phillips
Apr 18, 2011
kennytm@gmail.com
Apr 18, 2011
kennytm@gmail.com
April 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5853

           Summary: Sorting SysTime: overlapping array copy
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: Jesse.K.Phillips+D@gmail.com
                CC: Jesse.K.Phillips+D@gmail.com


--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2011-04-18 11:18:17 PDT ---
Sorting std.datetime.SysTime with std.algorithm.sort results in:

object.Exception@src\rt\arraycat.d(40): overlapping array copy

import std.algorithm;
import std.datetime;
import std.array;

void main() {
    auto arr = [
        SysTime(DateTime(2011,4,4)),
        SysTime(DateTime(2011,3,22))
        ];
    auto ans = [
        SysTime(DateTime(2011,3,22)),
        SysTime(DateTime(2011,4,4))
        ];
    assert(array(sort(arr)) == ans);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5853


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm@gmail.com


--- Comment #1 from kennytm@gmail.com 2011-04-18 12:23:38 PDT ---
I believe it is the same problem as issue 5705, except now the type to swap is a SysTime instead of a Tuple.

------------------------------------------------------------------
import std.algorithm;
import std.datetime;
import std.stdio;

void main() {
    auto x = SysTime(DateTime(2011,4,4));
    auto y = SysTime(DateTime(2011,4,4));
    swap(x, y);
    writeln("ok");
    swap(x, x);     // <-- throws "overlapping array copy"
    writeln("ok");
}
------------------------------------------------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5853


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from kennytm@gmail.com 2011-04-18 12:45:36 PDT ---
OK it is definitely issue 5705. Making std.algorithm.swap do nothing when &lhs == &rhs in case of hasElaborateAssign let the problem go away. Marking as dupe.

*** This issue has been marked as a duplicate of issue 5705 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------