Skip to content

Commit

Permalink
fix Issue 16197 - Constructors/postblits and destructors don't match …
Browse files Browse the repository at this point in the history
…up for array initialisation
  • Loading branch information
WalterBright committed May 13, 2017
1 parent d7edc71 commit 10c4f4a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ddmd/e2ir.d
Expand Up @@ -5632,7 +5632,7 @@ elem *toElemStructLit(StructLiteralExp sle, IRState *irs, TOK op, Symbol *sym, b
else
{
elem *edim = el_long(TYsize_t, t1b.size() / t2b.size());
e1 = setArray(e1, edim, t2b, ep, irs, op);
e1 = setArray(e1, edim, t2b, ep, irs, op == TOKconstruct ? TOKblit : op);
}
}
else
Expand Down
20 changes: 20 additions & 0 deletions test/runnable/sdtor.d
Expand Up @@ -4153,6 +4153,25 @@ int test14815()
}
static assert(test14815());

/**********************************/
// https://issues.dlang.org/show_bug.cgi?id=16197

struct Elem {
static string r;
int x = -1;
this(this) { r ~= 'p'; printf("POSTBLIT %d\n", x++); }
~this() { r ~= 'd'; printf("DTOR %d\n" , x++); }
}

struct Ctr {
Elem[3] arr;
}

void test16197() {
{ auto p = Ctr(); }
assert(Elem.r == "ddd");
}

/**********************************/
// 14860

Expand Down Expand Up @@ -4556,6 +4575,7 @@ int main()
test14264();
test14686();
test14815();
test16197();
test14860();
test14696();
test14838();
Expand Down

0 comments on commit 10c4f4a

Please sign in to comment.