Skip to content

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

@rsc

Description

@rsc

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)
    }
}
$ 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions