Open
Description
Using go1.17.5
.
In the following snippet:
bb := &Buffer{buf: make([]byte, 0, 64)}
bb.buf = append(bb.buf)
the buffer for make([]byte, 0, 64)
escapes to the heap because escape analysis cannot seem to determine that bb.buf = append(bb.buf)
does not cause buf
to escape.
I expect the code above to be able to stack allocate make([]byte, 0, 64)
.
\cc @josharian @mdempsky
@josharian theorizes that we might need a special case in https://github.com/golang/go/blame/master/src/cmd/compile/internal/escape/utils.go
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triage Backlog