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 bug #11387

Closed
rsc opened this issue Jun 24, 2015 · 1 comment
Closed

cmd/compile: escape analysis bug #11387

rsc opened this issue Jun 24, 2015 · 1 comment
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Jun 24, 2015

The compiler disagrees with the comment.

package main

func f(x []T) *[]T {
    y := make([]T, len(x))
    copy(y, x)
    return &y
}

type T struct {
    F func()
}

func create(x int) *[]T {
    return f([]T{
        {
            F: func() { panic(x) }, // DOES ESCAPE
        },
    })
}

func main() {
    var x int
    z := create(1)
    println(&x, (*z)[0].F)
    (*z)[0].F()
}
@rsc rsc added this to the Go1.5 milestone Jun 24, 2015
@gopherbot
Copy link

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

@rsc rsc closed this as completed in 6613090 Jun 24, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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