aboutsummaryrefslogtreecommitdiff
path: root/test/escape_iface.go
diff options
context:
space:
mode:
authorTal Shprecher <tshprecher@gmail.com>2016-07-13 12:29:39 -0600
committerDavid Chase <drchase@google.com>2016-10-10 12:09:16 +0000
commit672e57944458fc3c5f5ee1dd11d4f32d1aeaebe1 (patch)
tree39b6ecaa4ebe6987a89beddf7e08c0cc74dbdab3 /test/escape_iface.go
parent795289b114e4dd4f69eaa7f74cb9eb7b6f963fff (diff)
downloadgo-672e57944458fc3c5f5ee1dd11d4f32d1aeaebe1.tar.gz
go-672e57944458fc3c5f5ee1dd11d4f32d1aeaebe1.zip
cmd/compile: avoid leak of dottype expression on double assignment form
This is a followup to issue #13805. That change avoid leaks for types that don't have any pointers for the single assignment form of a dottype expression. This does the same for the double assignment form. Fixes #15796 Change-Id: I27474cade0ff1f3025cb6392f47b87b33542bc0f Reviewed-on: https://go-review.googlesource.com/24906 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/escape_iface.go')
-rw-r--r--test/escape_iface.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/escape_iface.go b/test/escape_iface.go
index 50a5132d1d..8a11d7eb82 100644
--- a/test/escape_iface.go
+++ b/test/escape_iface.go
@@ -226,22 +226,36 @@ func dotTypeEscape() *T2 { // #11931
}
}
-func dotTypeEscape2() { // #13805
+func dotTypeEscape2() { // #13805, #15796
{
i := 0
+ j := 0
var v int
+ var ok bool
var x interface{} = i // ERROR "i does not escape"
+ var y interface{} = j // ERROR "j does not escape"
+
*(&v) = x.(int) // ERROR "&v does not escape"
+ *(&v), *(&ok) = y.(int) // ERROR "&v does not escape" "&ok does not escape"
}
{
i := 0
+ j := 0
+ var ok bool
var x interface{} = i // ERROR "i does not escape"
- sink = x.(int) // ERROR "x.\(int\) escapes to heap"
+ var y interface{} = j // ERROR "j does not escape"
+ sink = x.(int) // ERROR "x.\(int\) escapes to heap"
+ sink, *(&ok) = y.(int) // ERROR "&ok does not escape"
}
{
i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
+ var ok bool
var x interface{} = &i // ERROR "&i escapes to heap"
+ var y interface{} = &j // ERROR "&j escapes to heap"
+
sink = x.(*int) // ERROR "x.\(\*int\) escapes to heap"
+ sink, *(&ok) = y.(*int) // ERROR "&ok does not escape"
}
}