Comment #0 by bearophile_hugs — 2011-11-02T17:12:14Z
D2 code:
void main() {
int[5] x;
x[x.length] = 1;
enum size_t n = 2;
x[x.length + n] = 2;
}
DMD 2.056 gives at compile-time:
test.d(3): Error: array index 5 is out of bounds x[0 .. 5]
test.d(5): Error: array index 7 is out of bounds x[0 .. 5]
I'd like this similar program to give similar compile-time errors (with DMD 2.056 it gives no compile errors, and gives just run-time errors in debug mode):
void main() {
int[5] x;
x[$] = 1;
enum size_t n = 2;
x[$ + n] = 2;
}
Comment #1 by bearophile_hugs — 2011-11-02T17:16:56Z
See also bug 6884
Comment #2 by bearophile_hugs — 2012-12-13T03:10:46Z