mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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
This commit is contained in:
parent
c56bb1d238
commit
572d984eaa
3 changed files with 41 additions and 4 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue