D2 Associative Arrays keys has a bug

soarowl soarowl at yeah.net
Thu Sep 2 03:28:14 PDT 2010


private import
    std.stdio;

static ubyte[] data = [1, 3, 5, 7, 9, 7, 5];

void main()
{
    int[ubyte] set;
    foreach(e; data) set[e]++;
    //foreach(k, v; set) std.stdio.writef("%d: %d ", k, v);
    foreach(e; set.keys.sort) std.stdio.writef("%d ", e);
    //foreach(e; set.values) std.stdio.writef("%d ", e);
}



I expect result: 1 3 5 7 9
But result will be: 0 0 0 1 5 or something else, which not equals expaect result.


More information about the Digitalmars-d-bugs mailing list