Skip to content

Commit

Permalink
Merge pull request #2682 from 9rnsr/fix11238
Browse files Browse the repository at this point in the history
[REG2.063] Issue 11238 - Codegen error when this is a ref parameter to the method
  • Loading branch information
WalterBright committed Oct 20, 2013
1 parent d32f639 commit f2c996a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/e2ir.c
Expand Up @@ -2761,6 +2761,7 @@ elem *AssignExp::toElem(IRState *irs)
*/
if (are->lwr == NULL && ta->ty == Tsarray &&
e2->op == TOKarrayliteral &&
op == TOKconstruct && // Bugzilla 11238: avoid aliasing issue
t2->nextOf()->mutableOf()->implicitConvTo(ta->nextOf()))
{
ArrayLiteralExp *ae = (ArrayLiteralExp *)e2;
Expand Down
20 changes: 20 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -3434,6 +3434,25 @@ void test2356()
bar() = [];
}

/***************************************************/
// 11238

void test11238()
{
int[2] m;
m[0] = 4,m[1] = 6;
//printf("%d,%d\n", m[0], m[1]);
assert(m[0] == 4 && m[1] == 6);

m = [m[1], m[0]]; // swap
assert(m[0] == 6 && m[1] == 4);
//printf("%d,%d\n", m[0], m[1]);

m = [m[1], m[0]]; // swap
//printf("%d,%d\n", m[0], m[1]);
assert(m[0] == 4 && m[1] == 6);
}

/***************************************************/

class A2540
Expand Down Expand Up @@ -6859,6 +6878,7 @@ int main()
test148();
test149();
test2356();
test11238();
test2540();
test150();
test151();
Expand Down

0 comments on commit f2c996a

Please sign in to comment.