summaryrefslogtreecommitdiff
path: root/test/escape4.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-09-24 15:53:12 -0400
committerRuss Cox <rsc@golang.org>2012-09-24 15:53:12 -0400
commitbd089d90d12aa726961adc6a015502da053127a8 (patch)
treef4358858a3c20b8119ee095e457242e484b84471 /test/escape4.go
parent4f55ef33a1e357fcf825bce7e8ab8fbcb70bd867 (diff)
downloadgo-bd089d90d12aa726961adc6a015502da053127a8.tar.gz
cmd/gc: fix escape analysis bug
Was not handling &x.y[0] and &x.y.z correctly where y is an array or struct-valued field (not a pointer). R=ken2 CC=golang-dev http://codereview.appspot.com/6551059
Diffstat (limited to 'test/escape4.go')
-rw-r--r--test/escape4.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/escape4.go b/test/escape4.go
index cc3ac78f0..83bc8eb12 100644
--- a/test/escape4.go
+++ b/test/escape4.go
@@ -37,3 +37,21 @@ func f2() {} // ERROR "can inline f2"
// No inline for panic, recover.
func f3() { panic(1) }
func f4() { recover() }
+
+func f5() *byte {
+ type T struct {
+ x [1]byte
+ }
+ t := new(T) // ERROR "new.T. escapes to heap"
+ return &t.x[0] // ERROR "&t.x.0. escapes to heap"
+}
+
+func f6() *byte {
+ type T struct {
+ x struct {
+ y byte
+ }
+ }
+ t := new(T) // ERROR "new.T. escapes to heap"
+ return &t.x.y // ERROR "&t.x.y escapes to heap"
+}