[Issue 1517] .sort for structs behaves badly with ref opCmp

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 17 20:10:49 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=1517


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc


--- Comment #2 from bearophile_hugs at eml.cc 2010-03-17 20:10:47 PDT ---
Reduced test case, on dmd v2.041:


struct S {
    int i;

    int opCmp(S other) {
        return this.i - other.i;
    }
}

void main() {
    S[S] aa;
    foreach (int i; [1, -1, 7])
        aa[S(i)] = S(-i);

    // wrong order:
    assert(aa.keys.sort == [S(1), S(7), S(-1)]);
}


If this is a real bug (and it seems so) then I think it's serious bug, it's
worse than a compiler crash, because the program runs unreliably.

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


More information about the Digitalmars-d-bugs mailing list