]> Cypherpunks repositories - gostls13.git/commitdiff
bug fix for &x[0] when x is slice
authorRuss Cox <rsc@golang.org>
Sun, 15 Feb 2009 21:15:46 +0000 (13:15 -0800)
committerRuss Cox <rsc@golang.org>
Sun, 15 Feb 2009 21:15:46 +0000 (13:15 -0800)
R=ken
OCL=25044
CL=25044

src/cmd/gc/walk.c

index 1d206334876819788bd71d0737da9afa1c925a71..f3a3bd6e55aadc715bf4ea869b252c9e18559386 100644 (file)
@@ -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;
        }
 }