aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/walk/complit.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/walk/complit.go')
-rw-r--r--src/cmd/compile/internal/walk/complit.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/walk/complit.go b/src/cmd/compile/internal/walk/complit.go
index abd920d6461..1f288d21c18 100644
--- a/src/cmd/compile/internal/walk/complit.go
+++ b/src/cmd/compile/internal/walk/complit.go
@@ -621,6 +621,12 @@ func oaslit(n *ir.AssignStmt, init *ir.Nodes) bool {
// not a special composite literal assignment
return false
}
+ if x.Addrtaken() {
+ // If x is address-taken, the RHS may (implicitly) uses LHS.
+ // Not safe to do a special composite literal assignment
+ // (which may expand to multiple assignments).
+ return false
+ }
switch n.Y.Op() {
default:
@@ -629,7 +635,7 @@ func oaslit(n *ir.AssignStmt, init *ir.Nodes) bool {
case ir.OSTRUCTLIT, ir.OARRAYLIT, ir.OSLICELIT, ir.OMAPLIT:
if ir.Any(n.Y, func(y ir.Node) bool { return ir.Uses(y, x) }) {
- // not a special composite literal assignment
+ // not safe to do a special composite literal assignment if RHS uses LHS.
return false
}
anylit(n.Y, n.X, init)