Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: ssa fails to flush return values during deferred func #14725

Closed
rsc opened this issue Mar 9, 2016 · 2 comments
Closed

cmd/compile: ssa fails to flush return values during deferred func #14725

rsc opened this issue Mar 9, 2016 · 2 comments

Comments

@rsc
Copy link
Contributor

rsc commented Mar 9, 2016

Reduced from a bug in cmd/doc found by @robpike.
/cc @khr @dr2chase

The -ssa=0 behavior is correct: the program should print 1, not 0.

$ go run -gcflags -ssa=0 /tmp/x.go
1
$ go run /tmp/x.go
0
$ cat /tmp/x.go
package main

func main() {
    println(f())
}

func f() (x int) {
    for {
        defer func() {
            recover()
            x = 1
        }()
        panic(1)
    }
}
$ 
@randall77
Copy link
Contributor

Upon further investigation, this seems unrelated to #14591. It looks like x is allocated on the heap and we never copy the heap value back to the stack at the end of the function (after deferreturn).

@gopherbot
Copy link

CL https://golang.org/cl/20486 mentions this issue.

@golang golang locked and limited conversation to collaborators Mar 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants