Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ go tool compile -m r.go | grep -e leaking -e new.int
- r.go:4:12: leaking param: f to result ~r1 level=1
- r.go:10:10: new(int) escapes to heap
- r.go:26:10: F2 new(int) does not escape
- $ cat r.go
- package p
- //go:noinline
- func call1(f func() error) error {
- // Leaks *f to result.
- return f()
- }
- func F1() error {
- y := new(int)
- return call1(func() error {
- y = nil
- return nil
- })
- }
- //go:noinline
- func call2(f func() error) error {
- // No param leakage.
- f()
- return nil
- }
- func F2() error {
- y := new(int)
- return call2(func() error {
- y = nil
- return nil
- })
- }
Add Comment
Please, Sign In to add comment