Skip to content

Commit

Permalink
Merge pull request #3665 from 9rnsr/fix12906
Browse files Browse the repository at this point in the history
[REG2.066a] Issue 12906 - [CTFE] Static array of structs causes postblit call
  • Loading branch information
WalterBright committed Jun 15, 2014
2 parents 1686e60 + 790212f commit 266ab51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/interpret.c
Expand Up @@ -4017,7 +4017,7 @@ class Interpreter : public Visitor
else
{
setValue(v, newval);
if (tyE1 == Tsarray && e->e2->isLvalue())
if (e->op != TOKblit && tyE1 == Tsarray && e->e2->isLvalue())
{
assert(newval->op == TOKarrayliteral);
ArrayLiteralExp *ale = (ArrayLiteralExp *)newval;
Expand Down Expand Up @@ -4560,7 +4560,7 @@ class Interpreter : public Visitor
{
(*oldelems)[(size_t)(j + firstIndex)] = paintTypeOntoLiteral(elemtype, (*newelems)[j]);
}
if (originalExp->e2->isLvalue())
if (originalExp->op != TOKblit && originalExp->e2->isLvalue())
{
Expression *x = evaluatePostblits(istate, existingAE, 0, oldelems->dim);
if (exceptionOrCantInterpret(x))
Expand Down Expand Up @@ -4644,7 +4644,7 @@ class Interpreter : public Visitor
assignInPlace((*existingAE->elements)[(size_t)(j+firstIndex)], newval);
}
}
if (!wantRef && !cow && originalExp->e2->isLvalue())
if (!wantRef && !cow && originalExp->op != TOKblit && originalExp->e2->isLvalue())
{
Expression *x = evaluatePostblits(istate, existingAE, (size_t)firstIndex, (size_t)(firstIndex+upperbound-lowerbound));
if (exceptionOrCantInterpret(x))
Expand Down
11 changes: 11 additions & 0 deletions test/compilable/interpret3.d
Expand Up @@ -6088,6 +6088,17 @@ bool test9245()
}
static assert(test9245());

/**************************************************
12906 don't call postblit on blit initializing
**************************************************/

struct S12906 { this(this) { assert(0); } }

static assert({
S12906[1] arr;
return true;
}());

/**************************************************
11510 support overlapped field access in CTFE
**************************************************/
Expand Down

0 comments on commit 266ab51

Please sign in to comment.