aboutsummaryrefslogtreecommitdiff
path: root/test/escape2.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/escape2.go')
-rw-r--r--test/escape2.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/escape2.go b/test/escape2.go
index 8cb3b6df66..28251aa98b 100644
--- a/test/escape2.go
+++ b/test/escape2.go
@@ -1468,3 +1468,25 @@ func foo152() {
v := NewV(u)
println(v)
}
+
+// issue 8176 - &x in type switch body not marked as escaping
+
+func foo153(v interface{}) *int { // ERROR "leaking param: v"
+ switch x := v.(type) {
+ case int: // ERROR "moved to heap: x"
+ return &x // ERROR "&x escapes to heap"
+ }
+ panic(0)
+}
+
+// issue 8185 - &result escaping into result
+
+func f() (x int, y *int) { // ERROR "moved to heap: x"
+ y = &x // ERROR "&x escapes to heap"
+ return
+}
+
+func g() (x interface{}) { // ERROR "moved to heap: x"
+ x = &x // ERROR "&x escapes to heap"
+ return
+}