Thread overview
[Issue 5773] New: sort() and topN() fail on sliced/resized array of tuples
Mar 23, 2011
Magnus Lie Hetland
Mar 23, 2011
Magnus Lie Hetland
Mar 23, 2011
kennytm@gmail.com
Mar 23, 2011
kennytm@gmail.com
March 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5773

           Summary: sort() and topN() fail on sliced/resized array of
                    tuples
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: magnus@hetland.org


--- Comment #0 from Magnus Lie Hetland <magnus@hetland.org> 2011-03-23 12:52:03 PDT ---
Sample program:

import std.algorithm, std.typecons;
void main() {
    alias Tuple!(real,uint) entry;
    auto entries = new entry[100];
    foreach (i, ref e; entries) {
        e[0] = 3.14*i;
        e[1] = i;
    }
    entries = entries[1 .. $];
    // sort(entries);
    // topN(entries, 50);
}

When uncommented (on their own), the sort statement gives a segmentation fault,
and the topN statement gives the error "object.Exception@src/rt/arraycat.d(40):
overlapping array copy".

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



--- Comment #1 from Magnus Lie Hetland <magnus@hetland.org> 2011-03-23 13:17:29 PDT ---
Perhaps this is just me being stupid -- trying to sort things that can't be compared? However, if I use a custom struct (instead of a tuple) I get an explicit compiler error about that (which is kind of useful ;-)

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


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


--- Comment #2 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-03-23 15:19:12 PDT ---
Thanks for the findings. They definitely point to bugs in sort and topN.

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


kennytm@gmail.com changed:

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


--- Comment #3 from kennytm@gmail.com 2011-03-23 16:00:52 PDT ---
(In reply to comment #1)
> Perhaps this is just me being stupid -- trying to sort things that can't be compared? However, if I use a custom struct (instead of a tuple) I get an explicit compiler error about that (which is kind of useful ;-)

Except that Tuples *can* can compared. Example:
----------
import std.typecons;
alias Tuple!(real,uint) Entry;
void main(){
    assert(Entry(1.0, 4) > Entry(0.5, 9));
}
-----------

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



--- Comment #4 from kennytm@gmail.com 2011-03-23 16:13:23 PDT ---
The overlapping array copy exception should be the same as issue 5705.

Not sure about the segfault, as I can't reproduce a segfault (only the same overlapping array copy exception is thrown).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5773


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-07 23:38:59 PST ---
Fixed as far back as 2.059.

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