aboutsummaryrefslogtreecommitdiff
path: root/test/escape2.go
diff options
context:
space:
mode:
authorRémy Oudompheng <oudomphe@phare.normalesup.org>2013-03-15 09:03:45 +0100
committerRémy Oudompheng <oudomphe@phare.normalesup.org>2013-03-15 09:03:45 +0100
commit20c7e41555e2c2b393c239f581ef7e216c795db4 (patch)
treeb686f7c6c6a0dc22eb87bd1e42b14525a475e433 /test/escape2.go
parent2924638d2631bf30f490e30ed120c4089c716b71 (diff)
downloadgo-20c7e41555e2c2b393c239f581ef7e216c795db4.tar.gz
go-20c7e41555e2c2b393c239f581ef7e216c795db4.zip
cmd/gc: fix escape analysis bug.
It used to not mark parameters as escaping if only one of the fields it points to leaks out of the function. This causes problems when importing from another package. Fixes #4964. R=rsc, lvd, dvyukov, daniel.morsing CC=golang-dev https://golang.org/cl/7648045
Diffstat (limited to 'test/escape2.go')
-rw-r--r--test/escape2.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/escape2.go b/test/escape2.go
index 9481619338..3473e4fa45 100644
--- a/test/escape2.go
+++ b/test/escape2.go
@@ -80,7 +80,9 @@ func foo12(yyy **int) { // ERROR "leaking param: yyy"
xxx = yyy
}
-func foo13(yyy **int) { // ERROR "yyy does not escape"
+// Must treat yyy as leaking because *yyy leaks, and the escape analysis
+// summaries in exported metadata do not distinguish these two cases.
+func foo13(yyy **int) { // ERROR "leaking param: yyy"
*xxx = *yyy
}
@@ -299,7 +301,8 @@ func (f *Foo) foo45() { // ERROR "f does not escape"
F.x = f.x
}
-func (f *Foo) foo46() { // ERROR "f does not escape"
+// See foo13 above for explanation of why f leaks.
+func (f *Foo) foo46() { // ERROR "leaking param: f"
F.xx = f.xx
}