diff options
author | Russ Cox <rsc@golang.org> | 2014-06-11 11:48:47 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-06-11 11:48:47 -0400 |
commit | c468e608829ebcac6c705246149a10287dfba238 (patch) | |
tree | 1cc8e3ffd13030e68ebbf22f074ae28166835e60 /test/escape2.go | |
parent | a9c27b77425f9c333591da1b7b1e02de415c5149 (diff) | |
download | go-c468e608829ebcac6c705246149a10287dfba238.tar.gz |
cmd/gc: fix escape analysis for &x inside switch x := v.(type)
The analysis for &x was using the loop depth on x set
during x's declaration. A type switch creates a list of
implicit declarations that were not getting initialized
with loop depths.
Fixes issue 8176.
LGTM=iant
R=iant
CC=golang-codereviews
https://codereview.appspot.com/108860043
Diffstat (limited to 'test/escape2.go')
-rw-r--r-- | test/escape2.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/escape2.go b/test/escape2.go index 8cb3b6df6..f00741dc2 100644 --- a/test/escape2.go +++ b/test/escape2.go @@ -1468,3 +1468,13 @@ 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) +} |