return *xx
}
-func foo9(xx, yy *int) *int { // ERROR "leaking param: xx to result ~r2 level=0$" "leaking param: yy to result ~r2 level=0$"
+func foo9(xx, yy *int) *int { // ERROR "leaking param: xx to result ~r0 level=0$" "leaking param: yy to result ~r0 level=0$"
xx = yy
return xx
}
}
func NewBar() *Bar {
- return &Bar{42, nil} // ERROR "&Bar literal escapes to heap$"
+ return &Bar{42, nil} // ERROR "&Bar{...} escapes to heap$"
}
func NewBarp(x *int) *Bar { // ERROR "leaking param: x$"
- return &Bar{42, x} // ERROR "&Bar literal escapes to heap$"
+ return &Bar{42, x} // ERROR "&Bar{...} escapes to heap$"
}
func NewBarp2(x *int) *Bar { // ERROR "x does not escape$"
- return &Bar{*x, nil} // ERROR "&Bar literal escapes to heap$"
+ return &Bar{*x, nil} // ERROR "&Bar{...} escapes to heap$"
}
func (b *Bar) NoLeak() int { // ERROR "b does not escape$"
}
func NewBar2() *Bar2 {
- return &Bar2{[12]int{42}, nil} // ERROR "&Bar2 literal escapes to heap$"
+ return &Bar2{[12]int{42}, nil} // ERROR "&Bar2{...} escapes to heap$"
}
func (b *Bar2) NoLeak() int { // ERROR "b does not escape$"
return &x
}
-func indaddr2(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$"
+func indaddr2(x *int) *int { // ERROR "leaking param: x to result ~r0 level=0$"
return *&x
}
-func indaddr3(x *int32) *int { // ERROR "leaking param: x to result ~r1 level=0$"
+func indaddr3(x *int32) *int { // ERROR "leaking param: x to result ~r0 level=0$"
return *(**int)(unsafe.Pointer(&x))
}
return (*uint64)(unsafe.Pointer(&f))
}
-func float64ptrbitsptr(f *float64) *uint64 { // ERROR "leaking param: f to result ~r1 level=0$"
+func float64ptrbitsptr(f *float64) *uint64 { // ERROR "leaking param: f to result ~r0 level=0$"
return (*uint64)(unsafe.Pointer(f))
}
-func typesw(i interface{}) *int { // ERROR "leaking param: i to result ~r1 level=0$"
+func typesw(i interface{}) *int { // ERROR "leaking param: i to result ~r0 level=0$"
switch val := i.(type) {
case *int:
return val
return nil
}
-func exprsw(i *int) *int { // ERROR "leaking param: i to result ~r1 level=0$"
+func exprsw(i *int) *int { // ERROR "leaking param: i to result ~r0 level=0$"
switch j := i; *j + 110 {
case 12:
return j
}
// assigning to an array element is like assigning to the array
-func foo60(i *int) *int { // ERROR "leaking param: i to result ~r1 level=0$"
+func foo60(i *int) *int { // ERROR "leaking param: i to result ~r0 level=0$"
var a [12]*int
a[0] = i
return a[1]
}
// assigning to a struct field is like assigning to the struct
-func foo61(i *int) *int { // ERROR "leaking param: i to result ~r1 level=0$"
+func foo61(i *int) *int { // ERROR "leaking param: i to result ~r0 level=0$"
type S struct {
a, b *int
}
// issue 2145
func foo73() {
- s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape$"
+ s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$"
for _, v := range s {
vv := v
// actually just escapes its scope
}
func foo731() {
- s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape$"
+ s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$"
for _, v := range s {
vv := v // ERROR "moved to heap: vv$"
// actually just escapes its scope
}
func foo74() {
- s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape$"
+ s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$"
for _, v := range s {
vv := v
// actually just escapes its scope
}
func foo74a() {
- s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape$"
+ s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$"
for _, v := range s {
vv := v // ERROR "moved to heap: vv$"
// actually just escapes its scope
// issue 3975
func foo74b() {
var array [3]func()
- s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape$"
+ s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$"
for i, v := range s {
vv := v
// actually just escapes its scope
func foo74c() {
var array [3]func()
- s := []int{3, 2, 1} // ERROR "\[\]int literal does not escape$"
+ s := []int{3, 2, 1} // ERROR "\[\]int{...} does not escape$"
for i, v := range s {
vv := v // ERROR "moved to heap: vv$"
// actually just escapes its scope
}
}
-func myprint(y *int, x ...interface{}) *int { // ERROR "leaking param: y to result ~r2 level=0$" "x does not escape$"
+func myprint(y *int, x ...interface{}) *int { // ERROR "leaking param: y to result ~r0 level=0$" "x does not escape$"
return y
}
-func myprint1(y *int, x ...interface{}) *interface{} { // ERROR "leaking param: x to result ~r2 level=0$" "y does not escape$"
+func myprint1(y *int, x ...interface{}) *interface{} { // ERROR "leaking param: x to result ~r0 level=0$" "y does not escape$"
return &x[0]
}
func foo76f() {
for {
// TODO: This one really only escapes its scope, but we don't distinguish yet.
- defer myprint(nil, 1, 2, 3) // ERROR "... argument escapes to heap$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$"
+ defer myprint(nil, 1, 2, 3) // ERROR "... argument does not escape$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$"
}
}
func foo76g() {
for {
- defer myprint1(nil, 1, 2, 3) // ERROR "... argument escapes to heap$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$"
+ defer myprint1(nil, 1, 2, 3) // ERROR "... argument does not escape$" "1 escapes to heap$" "2 escapes to heap$" "3 escapes to heap$"
}
}
}
func LimitFooer(r Fooer, n int64) Fooer { // ERROR "leaking param: r$"
- return &LimitedFooer{r, n} // ERROR "&LimitedFooer literal escapes to heap$"
+ return &LimitedFooer{r, n} // ERROR "&LimitedFooer{...} escapes to heap$"
}
func foo90(x *int) map[*int]*int { // ERROR "leaking param: x$"
- return map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int literal escapes to heap$"
+ return map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int{...} escapes to heap$"
}
func foo91(x *int) map[*int]*int { // ERROR "leaking param: x$"
- return map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int literal escapes to heap$"
+ return map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int{...} escapes to heap$"
}
-func foo92(x *int) [2]*int { // ERROR "leaking param: x to result ~r1 level=0$"
+func foo92(x *int) [2]*int { // ERROR "leaking param: x to result ~r0 level=0$"
return [2]*int{x, nil}
}
}
// does not leak m
-func foo94(m map[*int]*int, b bool) *int { // ERROR "leaking param: m to result ~r2 level=1"
+func foo94(m map[*int]*int, b bool) *int { // ERROR "leaking param: m to result ~r0 level=1"
for k, v := range m {
if b {
return k
}
// does not leak m but does leak content
-func foo96(m []*int) *int { // ERROR "leaking param: m to result ~r1 level=1"
+func foo96(m []*int) *int { // ERROR "leaking param: m to result ~r0 level=1"
return m[0]
}
// does leak m
-func foo97(m [1]*int) *int { // ERROR "leaking param: m to result ~r1 level=0$"
+func foo97(m [1]*int) *int { // ERROR "leaking param: m to result ~r0 level=0$"
return m[0]
}
}
// does leak m
-func foo99(m *[1]*int) []*int { // ERROR "leaking param: m to result ~r1 level=0$"
+func foo99(m *[1]*int) []*int { // ERROR "leaking param: m to result ~r0 level=0$"
return m[:]
}
// does not leak m
-func foo100(m []*int) *int { // ERROR "leaking param: m to result ~r1 level=1"
+func foo100(m []*int) *int { // ERROR "leaking param: m to result ~r0 level=1"
for _, v := range m {
return v
}
}
// does leak m
-func foo101(m [1]*int) *int { // ERROR "leaking param: m to result ~r1 level=0$"
+func foo101(m [1]*int) *int { // ERROR "leaking param: m to result ~r0 level=0$"
for _, v := range m {
return v
}
}
func foo107(x *int) map[*int]*int { // ERROR "leaking param: x$"
- return map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int literal escapes to heap$"
+ return map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int{...} escapes to heap$"
}
func foo108(x *int) map[*int]*int { // ERROR "leaking param: x$"
- return map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int literal escapes to heap$"
+ return map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int{...} escapes to heap$"
}
func foo109(x *int) *int { // ERROR "leaking param: x$"
- m := map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int literal does not escape$"
+ m := map[*int]*int{x: nil} // ERROR "map\[\*int\]\*int{...} does not escape$"
for k, _ := range m {
return k
}
}
func foo110(x *int) *int { // ERROR "leaking param: x$"
- m := map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int literal does not escape$"
+ m := map[*int]*int{nil: x} // ERROR "map\[\*int\]\*int{...} does not escape$"
return m[nil]
}
-func foo111(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0"
- m := []*int{x} // ERROR "\[\]\*int literal does not escape$"
+func foo111(x *int) *int { // ERROR "leaking param: x to result ~r0 level=0"
+ m := []*int{x} // ERROR "\[\]\*int{...} does not escape$"
return m[0]
}
-func foo112(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$"
+func foo112(x *int) *int { // ERROR "leaking param: x to result ~r0 level=0$"
m := [1]*int{x}
return m[0]
}
-func foo113(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$"
+func foo113(x *int) *int { // ERROR "leaking param: x to result ~r0 level=0$"
m := Bar{ii: x}
return m.ii
}
-func foo114(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$"
- m := &Bar{ii: x} // ERROR "&Bar literal does not escape$"
+func foo114(x *int) *int { // ERROR "leaking param: x to result ~r0 level=0$"
+ m := &Bar{ii: x} // ERROR "&Bar{...} does not escape$"
return m.ii
}
-func foo115(x *int) *int { // ERROR "leaking param: x to result ~r1 level=0$"
+func foo115(x *int) *int { // ERROR "leaking param: x to result ~r0 level=0$"
return (*int)(unsafe.Pointer(uintptr(unsafe.Pointer(x)) + 1))
}
func foo121() {
for i := 0; i < 10; i++ {
- defer myprint(nil, i) // ERROR "... argument escapes to heap$" "i escapes to heap$"
- go myprint(nil, i) // ERROR "... argument escapes to heap$" "i escapes to heap$"
+ defer myprint(nil, i) // ERROR "... argument does not escape$" "i escapes to heap$"
+ go myprint(nil, i) // ERROR "... argument does not escape$" "i escapes to heap$"
}
}
// same as foo121 but check across import
func foo121b() {
for i := 0; i < 10; i++ {
- defer fmt.Printf("%d", i) // ERROR "... argument escapes to heap$" "i escapes to heap$"
- go fmt.Printf("%d", i) // ERROR "... argument escapes to heap$" "i escapes to heap$"
+ defer fmt.Printf("%d", i) // ERROR "... argument does not escape$" "i escapes to heap$"
+ go fmt.Printf("%d", i) // ERROR "... argument does not escape$" "i escapes to heap$"
}
}
X string
T *T
}
- t := &T{} // ERROR "&T literal escapes to heap$"
- return U{ // ERROR "U literal escapes to heap$"
+ t := &T{} // ERROR "&T{} escapes to heap$"
+ return U{ // ERROR "U{...} escapes to heap$"
X: t.X,
T: t,
}
func foo141() {
var f func()
- t := new(Tm) // ERROR "new\(Tm\) escapes to heap$"
+ t := new(Tm) // ERROR "new\(Tm\) does not escape$"
f = t.M // ERROR "t.M does not escape$"
_ = f
}
}
func NewV(u U) *V { // ERROR "leaking param: u$"
- return &V{u.String()} // ERROR "&V literal escapes to heap$"
+ return &V{u.String()} // ERROR "&V{...} escapes to heap$"
}
func foo152() {
case int: // ERROR "moved to heap: x$"
return &x
}
- panic(0)
+ panic(0) // ERROR "0 escapes to heap"
}
// issue 8185 - &result escaping into result
func ptrlitNoescape() {
// Both literal and element do not escape.
i := 0
- x := &Lit{&i} // ERROR "&Lit literal does not escape$"
+ x := &Lit{&i} // ERROR "&Lit{...} does not escape$"
_ = x
}
func ptrlitNoEscape2() {
// Literal does not escape, but element does.
i := 0 // ERROR "moved to heap: i$"
- x := &Lit{&i} // ERROR "&Lit literal does not escape$"
+ x := &Lit{&i} // ERROR "&Lit{...} does not escape$"
sink = *x
}
func ptrlitEscape() {
// Both literal and element escape.
i := 0 // ERROR "moved to heap: i$"
- x := &Lit{&i} // ERROR "&Lit literal escapes to heap$"
+ x := &Lit{&i} // ERROR "&Lit{...} escapes to heap$"
sink = x
}
func stringtoslicebyte0() {
s := "foo"
- x := []byte(s) // ERROR "\(\[\]byte\)\(s\) does not escape$"
+ x := []byte(s) // ERROR "\(\[\]byte\)\(s\) does not escape$" "zero-copy string->\[\]byte conversion"
_ = x
}
}
func slicerunetostring0() {
- r := []rune{1, 2, 3} // ERROR "\[\]rune literal does not escape$"
+ r := []rune{1, 2, 3} // ERROR "\[\]rune{...} does not escape$"
s := string(r) // ERROR "string\(r\) does not escape$"
_ = s
}
func slicerunetostring1() string {
- r := []rune{1, 2, 3} // ERROR "\[\]rune literal does not escape$"
+ r := []rune{1, 2, 3} // ERROR "\[\]rune{...} does not escape$"
return string(r) // ERROR "string\(r\) escapes to heap$"
}
func slicerunetostring2() {
- r := []rune{1, 2, 3} // ERROR "\[\]rune literal does not escape$"
+ r := []rune{1, 2, 3} // ERROR "\[\]rune{...} does not escape$"
sink = string(r) // ERROR "string\(r\) escapes to heap$"
}