Reported by Ali Cehreli. void main() { int[4] static_1 = [ 3:212 ]; } PATCH against DMD2.031. We need to make sure the array literal is big enough to include the last mentioned element. We need to return ErrorExp, not NULL, otherwise it will still segfault on cases like int[4] x = [32: 1]; because VerDeclaration::semantic assumes a NULL result means that it should run semantic on the initializer. Index: init.c =================================================================== --- init.c (revision 194) +++ init.c (working copy) @@ -422,6 +422,13 @@ else edim = value.dim; + for (size_t i = 0, j = 0; i < value.dim; i++, j++) + { + if (index.data[i]) + j = ((Expression *)index.data[i])->toInteger(); + if (j >=edim) edim = j+1; + } + elements = new Expressions(); elements->setDim(edim); for (size_t i = 0, j = 0; i < value.dim; i++, j++) @@ -464,7 +471,7 @@ Lno: delete elements; error(loc, "array initializers as expressions are not allowed"); - return NULL; + return new ErrorExp(); }
Fixed dmd 1.047 and 2.032