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
func f(p, q *int) (r *int) {
r = p
defer func() {
recover()
}()
g()
r = q
return
}
func g()
At the call to g, r should be marked as live. It isn't.
> go tool compile -live ~/go/tmp3.go
tmp3.go:3: live at entry to f: p q
tmp3.go:7: live at call to deferproc: q r
tmp3.go:8: live at call to g: q <- r is live here
tmp3.go:10: live at call to deferreturn: r
tmp3.go:7: live at call to deferreturn: r
Any defer makes all of the output args live at any (possibly panicing) call.
Found using the dead-slot clobberer, https://go-review.googlesource.com/c/23924/
Seems to be around for a while, at least 1.6.
I'm not sure why the dead-slot clobberer didn't find this before.
(Note to self: original detection from encoding/gob/encoder_test.go:encodeAndRecover.)
Activity
randall77 commentedon Jan 30, 2017
@aclements
gopherbot commentedon Jan 30, 2017
CL https://golang.org/cl/36030 mentions this issue.
gopherbot commentedon Feb 3, 2017
CL https://golang.org/cl/23924 mentions this issue.
gopherbot commentedon Mar 13, 2017
CL https://golang.org/cl/38133 mentions this issue.
cmd/compile: zero return parameters earlier
cmd/compile: experiment which clobbers all dead pointer fields