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: escape analysis overconservative for recursive calls #13547

dr2chase opened this issue Dec 9, 2015 · 2 comments


None yet
5 participants
Copy link

commented Dec 9, 2015

Sample program. Allocation in inner loop of recursive foo does not escape, but conservative assumptions (because escape analysis does not do fixed-pointer iteration) force conclusion that it does.

package main
// import "fmt"
type Node struct {
    next *Node
    name string
var sink string
func foo(list *Node, names []string) {
    if len(names) > 0 {
        name := names[0]
        for i := 0; i < len(name); i++ {
            foo(&Node{list, name[i : i+1]}, names[1:]) // need not escape
    } else if list != nil {
        // fmt.Printf("%s", // you don't want to to do this unless you are comparing output.
        sink =
        foo(, names)
func main() {
    names := []string{"ant", "bat", "cat", "dog", "emu",
        "fox", "gnu", "hyena", "iguana", "jaguar"}
    foo(nil, names)

This comment has been minimized.

Copy link

commented Dec 9, 2015

CL mentions this issue.

@rsc rsc added this to the Go1.7Early milestone Dec 28, 2015

@bradfitz bradfitz modified the milestones: Go1.8Early, Go1.7Early May 6, 2016


This comment has been minimized.

Copy link

commented May 6, 2016

Didn't happen for 1.7.

@quentinmit quentinmit added the NeedsFix label Oct 6, 2016

@rsc rsc modified the milestones: Unplanned, Go1.8Early Oct 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.