Changing platform to All (affects Linux too).
Similar code:
void[] p = [cast(void)42];
As of DMD-2.051, now prints:
Internal error: ../ztc/cod1.c 3057
Comment #2 by ibuclaw — 2011-04-11T14:39:36Z
diff --git a/src/expression.c b/src/expression.c
index 9d116b9..1bd9e42 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -3200,6 +3200,10 @@ Expression *ArrayLiteralExp::semantic(Scope *sc)
type = t0->arrayOf();
//type = new TypeSArray(t0, new IntegerExp(elements->dim));
type = type->semantic(loc, sc);
+
+ if (type->nextOf()->ty == Tvoid)
+ error("array literal of type void[] has no value");
+
return this;
}
Comment #3 by ibuclaw — 2011-04-11T14:44:50Z
Maybe
if (type->nextOf()->ty == Tvoid)
error("%s of type void[] has no value", toChars());
Is a better error message (I really am no good at writing them :)
Comment #4 by ibuclaw — 2011-04-14T04:36:55Z
Oops, previous patch didn't take into account that empty '[]' array literals are allowed to be void.
diff --git a/src/expression.c b/src/expression.c
index 9d116b9..1e68ce7 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -3197,6 +3197,9 @@ Expression *ArrayLiteralExp::semantic(Scope *sc)
Type *t0;
elements = arrayExpressionToCommonType(sc, elements, &t0);
+ if (elements->dim > 0 && t0->ty == Tvoid)
+ error("array literal %s has no value", toChars());
+
type = t0->arrayOf();
//type = new TypeSArray(t0, new IntegerExp(elements->dim));
type = type->semantic(loc, sc);
Comment #5 by kennytm — 2011-05-05T11:45:10Z
*** Issue 5929 has been marked as a duplicate of this issue. ***