www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3638] New: stable sort assertion failure for repeated key sequence

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3638

           Summary: stable sort assertion failure for repeated key
                    sequence
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrew.talbot talbotville.com



13:40:32 PST ---
Performing a stable sort on a repeated pair of keys that are already in sorted
order causes the following error message.

core.exception.AssertError std.algorithm(3736): Assertion failure

However, doing so with repeated reverse-sorted keys works fine.

In other words, a stable sort of the array
[ "B", "A", "B", A" ] will succeed, but one of ["A", "B", "A", "B" ] will fail.

Illustrative code:

import std.algorithm;
import std.stdio;

void main()
{
    auto ar1 = [ "B", "A", "B", "A" ];
    sort!("a <  b", SwapStrategy.stable)(ar1); // ok
    writeln(ar1);

    auto ar2 = [ "A", "B", "A", "B" ];
    sort!("a <  b", SwapStrategy.stable)(ar2); // fails
    writeln(ar2);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 21 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3638


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com



14:23:34 PST ---
Thanks for the report.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 21 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3638


Andrew Talbot <andrew.talbot talbotville.com> changed:

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



07:59:37 PDT ---
Fixed in version dmd 2.054.

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