aboutsummaryrefslogtreecommitdiff
path: root/test/escape2n.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-06-24 17:31:57 -0400
committerRuss Cox <rsc@golang.org>2015-06-24 22:22:55 +0000
commit66130907d1483f851b514ab564c64fe1d1fceec6 (patch)
tree3d9ea66fe50fc92f6cf28cb548f2e1a18c3bc93e /test/escape2n.go
parenta9e536442ed3e6ecd57ec24cc187557152b6d655 (diff)
downloadgo-66130907d1483f851b514ab564c64fe1d1fceec6.tar.gz
go-66130907d1483f851b514ab564c64fe1d1fceec6.zip
cmd/compile: handle copy in escape analysis
Somehow we missed this! Fixes #11387. Change-Id: Ida08fe52eff7da2ef7765b4cf35a39a301420c43 Reviewed-on: https://go-review.googlesource.com/11460 Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/escape2n.go')
-rw-r--r--test/escape2n.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/escape2n.go b/test/escape2n.go
index f1481c1a36..c32877321f 100644
--- a/test/escape2n.go
+++ b/test/escape2n.go
@@ -858,8 +858,8 @@ func foo103(m [1]*int, x *int) { // ERROR "foo103 m does not escape$" "foo103 x
var y []*int
-// does not leak x
-func foo104(x []*int) { // ERROR "foo104 x does not escape$"
+// does not leak x but does leak content
+func foo104(x []*int) { // ERROR "leaking param content: x"
copy(y, x)
}
@@ -1820,3 +1820,11 @@ func issue10353b() {
}
_ = f
}
+
+func issue11387(x int) func() int {
+ f := func() int { return x } // ERROR "func literal escapes to heap"
+ slice1 := []func() int{f} // ERROR "\[\].* does not escape"
+ slice2 := make([]func() int, 1) // ERROR "make\(.*\) does not escape"
+ copy(slice2, slice1)
+ return slice2[0]
+}