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 on slice allocations #39793

Closed
hagaidayan opened this issue Jun 23, 2020 · 2 comments
Closed

cmd/compile: escape analysis on slice allocations #39793

hagaidayan opened this issue Jun 23, 2020 · 2 comments

Comments

@hagaidayan
Copy link

What version of Go are you using (go version)?

$ go version 1.13

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

2.3 GHz Dual-Core Intel Core i5

Mac OSX

go env Output
$ go env

What did you do?

I wrote 2 similar programs that do the same thing
then built them with ' go build -gcflags "-m -m -l -N" '

A.
func main () {
x := 10
arr := make([]int, x)
arr[0] = 0
}

B.
func main () {
arr := make([]int, 10)
arr[0] = 0
}

What did you expect to see?

that both programs either do, or do not produce heap allocations

What did you see instead?

program A escapes to heap in line 3, while program B doesn't

@randall77
Copy link
Contributor

Probably a dup of #29095

@cagedmantis
Copy link
Contributor

As mentioned above this issue is captured in #29095. Please feel free to comment if you feel this was closed in error.

@golang golang locked and limited conversation to collaborators Jun 29, 2021
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

4 participants