Sorry for the noob questions, but

import std.stdio;

struct Foo {
    int x;
}
void main() {
    auto array = new Foo[10];
    auto i = array.length;
    foreach(Foo f; array) { f.x = --i; write(f.x);}
    writeln();
    foreach(Foo f; array) { write(f.x);}
}

gives me:

PS E:\DigitalMars\dmd2\samples> rdmd bug.d
9876543210
0000000000

Also,

void main() {
    auto array = new Foo[10];
--> for(int i = array.length; i > 1; i--) { array[i].x = i; }
    writeln();
    foreach(Foo f; array) { write(f.x);}
}

throws core.exception.RangeError@bug(8): Range violation on the line with the arrow.

What am I doing wrong ?

Reply via email to