arrays: Disalllow void array block assignment

This commit is contained in:
David Nadlinger 2015-07-27 21:05:30 +02:00
parent 63337b278a
commit eb96b8ab44

View file

@ -263,7 +263,18 @@ void DtoArrayAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPost
LLValue* lhsLength = DtoArrayLen(lhs);
// TODO: This should use AssignExp::ismemset.
if (!t2->implicitConvTo(t->nextOf()))
// Disallow void array block assignment (DMD issue 7493).
bool canBeBlockAssignment = true;
if (!rhs->isNull())
{
Type *leafElemType = elemType;
while (leafElemType->ty == Tarray)
{
leafElemType = leafElemType->nextOf();
}
canBeBlockAssignment = leafElemType->ty != Tvoid;
}
if (!t2->implicitConvTo(t->nextOf()) || !canBeBlockAssignment)
{
// T[] = T[] T[] = T[n]
// T[n] = T[n] T[n] = T[]