diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 0567fbdf90ee..978ca8db8fe6 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2679,15 +2679,30 @@ proc genTupleConstr(p: BProc, n: PNode, d: var TLoc) = if not handleConstExpr(p, n, d): let t = n.typ discard getTypeDesc(p.module, t) # so that any fields are initialized - if d.k == locNone: getTemp(p, t, d) + + var tmp: TLoc + # bug #16331 + let doesAlias = lhsDoesAlias(d.lode, n) + let dest = if doesAlias: addr(tmp) else: addr(d) + if doesAlias: + getTemp(p, n.typ, tmp) + elif d.k == locNone: + getTemp(p, n.typ, d) + for i in 0..