From f2c996a0220230762677a665842f402f576499c5 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Sun, 20 Oct 2013 10:20:05 -0700 Subject: [PATCH] Merge pull request #2682 from 9rnsr/fix11238 [REG2.063] Issue 11238 - Codegen error when this is a ref parameter to the method --- src/e2ir.c | 1 + test/runnable/xtest46.d | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/e2ir.c b/src/e2ir.c index dab486073783..feb7d39bfd44 100644 --- a/src/e2ir.c +++ b/src/e2ir.c @@ -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; diff --git a/test/runnable/xtest46.d b/test/runnable/xtest46.d index 46a145567152..99ac232e418c 100644 --- a/test/runnable/xtest46.d +++ b/test/runnable/xtest46.d @@ -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 @@ -6859,6 +6878,7 @@ int main() test148(); test149(); test2356(); + test11238(); test2540(); test150(); test151();