[Issue 2333] Hash initializer does not work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 3 05:57:17 PDT 2008


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


gide at nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid             |wrong-code




------- Comment #5 from gide at nwawudu.com  2008-09-03 07:57 -------
In that case my comment on bug 1727 was valid, I'll repeat it here. The
following code compiles on both GDC and DMD, but DMD compiled code throws an
array bounds exception when executed.

test.d
------
import std.stdio;

void main() {
        int[char[]] aa =  ["aa":1, "bb":2, "cc":3]; // Fails later
        //int[char[]] aa; aa =  ["aa":1, "bb":2, "cc":3]; // Fails later 
        //int[char[]] aa; aa["aa"] = 1; aa["bb"] = 2; aa["cc"] = 3; // OK

        assert(aa.length == 3);
        assert(aa["aa"]==1); // DMD fails here. Error: ArrayBoundsError test(9)
        writefln(aa["aa"],aa["bb"],aa["cc"]); // On GDC output -> 123
}


-- 



More information about the Digitalmars-d-bugs mailing list