www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5773] New: sort() and topN() fail on sliced/resized array of tuples

reply d-bugmail puremagic.com writes:
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



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: -------
Mar 23 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5773




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: -------
Mar 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Mar 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5773


kennytm gmail.com changed:

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




 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: -------
Mar 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5773




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: -------
Mar 23 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5773


Andrei Alexandrescu <andrei erdani.com> changed:

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



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: -------
Jan 07 2013