diff options
author | Russ Cox <rsc@golang.org> | 2013-02-04 22:48:31 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2013-02-04 22:48:31 -0500 |
commit | 572d984eaa64e6e3a1a67ecde9f6a1038d76becc (patch) | |
tree | 42cf53effc415c3b7a85d597e0e233e57716baa5 /test/escape2.go | |
parent | c56bb1d238672f658c4f5f5e1efc0fa88c3b3101 (diff) | |
download | go-572d984eaa64e6e3a1a67ecde9f6a1038d76becc.tar.gz go-572d984eaa64e6e3a1a67ecde9f6a1038d76becc.zip |
cmd/gc: fix escape analysis
If the analysis reached a node twice, then the analysis was cut off.
However, if the second arrival is at a lower depth (closer to escaping)
then it is important to repeat the traversal.
The repeating must be cut off at some point to avoid the occasional
infinite recursion. This CL cuts it off as soon as possible while still
passing all tests.
Fixes #4751.
R=ken2
CC=golang-dev, lvd
https://golang.org/cl/7303043
Diffstat (limited to 'test/escape2.go')
-rw-r--r-- | test/escape2.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/escape2.go b/test/escape2.go index 6c39566fec..8e3aa4de74 100644 --- a/test/escape2.go +++ b/test/escape2.go @@ -1258,3 +1258,19 @@ func foo139() *byte { t := new(T) // ERROR "new.T. escapes to heap" return &t.x.y // ERROR "&t.x.y escapes to heap" } + +// issue 4751 +func foo140() interface{} { + type T struct { + X string + } + type U struct { + X string + T *T + } + t := &T{} // ERROR "&T literal escapes to heap" + return U{ + X: t.X, + T: t, + } +} |