summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/gc/walk.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c
index 1d2063348..f3a3bd6e5 100644
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -3745,10 +3745,13 @@ addrescapes(Node *n)
case ODOT:
case OINDEX:
- // ODOTPTR has already been
- // introduced, so these are the non-pointer
- // ODOT and OINDEX.
- addrescapes(n->left);
+ // ODOTPTR has already been introduced,
+ // so these are the non-pointer ODOT and OINDEX.
+ // In &x[0], if x is a slice, then x does not
+ // escape--the pointer inside x does, but that
+ // is always a heap pointer anyway.
+ if(!isslice(n->left->type))
+ addrescapes(n->left);
break;
}
}