Thread overview
[Issue 7115] New: sort function is broken with large arrays
Dec 15, 2011
deadalnix
Dec 15, 2011
timon.gehr@gmx.ch
Dec 15, 2011
deadalnix
Dec 16, 2011
Don
December 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7115

           Summary: sort function is broken with large arrays
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: deadalnix@gmail.com


--- Comment #0 from deadalnix <deadalnix@gmail.com> 2011-12-15 13:38:40 PST ---
See sample code :

module fail;

import std.algorithm;
import std.random;

void main() {
    Mt19937 gen;

    byte[] v;
    v.length = 65536 * 1024;

    foreach(ref byte t; v) {
        t = cast(byte) gen.front;
        gen.popFront;
    }

    v.sort;

    assert(isSorted(v));
}

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


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch


--- Comment #1 from timon.gehr@gmx.ch 2011-12-15 13:52:00 PST ---
This would be a great opportunity to finally deprecate that abomination. Also, I think this only happens when the element type is byte?

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



--- Comment #2 from deadalnix <deadalnix@gmail.com> 2011-12-15 13:58:57 PST ---
(In reply to comment #1)
> This would be a great opportunity to finally deprecate that abomination. Also, I think this only happens when the element type is byte?

I did put byte for performances reasons, but it is true that it works with int and short (I just checked). Anyway, not sure it will nto fail for bigger values.

BTW, phobos provide nice way to sort, so this feature is not really needed and can be deprecated.

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-12-16 03:51:42 PST ---
Perhaps a duplicate of bug 2819?
(I think it may be overflowing the stack, and generating wrong results instead
of segfaulting).

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