You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ go version
go version devel +2e4edf4697 Sun May 12 07:14:09 2019 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
$ cat escape.go
package escape
type F struct {
}
func (f *F) Do() *F {
// ... mutate f ...
return f
}
$ go build -gcflags="-m -l" escape.go
# command-line-arguments
./escape.go:6:7: leaking param: f to result ~r0 level=0
What did you expect to see?
That f does not escape.
What did you see instead?
f escapes.
I suppose a fix for this issue will also cover returning arguments and not just the method receiver, but the above simplified case matches my use better (method chaining).
The text was updated successfully, but these errors were encountered:
eliasnaur
changed the title
cmd/compile: returning arguments should not escape
cmd/compile: returning arguments should not cause their escape
May 14, 2019
We currently only compile (*F).Do once. And somebody might write
varV*FfuncDoIt(f*F) {
V=f.Do()
}
So I don't see how to avoid this escape. Other than compiling the method in two different ways, and choosing the implementation based on whether the result escapes.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
What did you expect to see?
That f does not escape.
What did you see instead?
f escapes.
I suppose a fix for this issue will also cover returning arguments and not just the method receiver, but the above simplified case matches my use better (method chaining).
The text was updated successfully, but these errors were encountered: