// BAD: i should not escape
i := 0 // ERROR "moved to heap: i"
// BAD: j should not escape
- j := 0 // ERROR "moved to heap: j"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
_ = m
}
func map1() *int {
m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
// BAD: i should not escape
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
return m[&i]
}
m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
i := 0 // ERROR "moved to heap: i"
// BAD: j should not escape
- j := 0 // ERROR "moved to heap: j"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
var r []*int
for k := range m {
func map4() []*int {
m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
// BAD: i should not escape
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
var r []*int
for k, v := range m {
}
func map5(m map[*int]*int) { // ERROR "m does not escape"
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
}
if m != nil {
m = make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
}
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
}
i := 0 // ERROR "moved to heap: i"
// BAD: j should not escape
j := 0 // ERROR "moved to heap: j"
- m := map[*int]*int{&i: &j} // ERROR "literal does not escape"
+ m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} does not escape"
_ = m
}
func map8() {
i := 0 // ERROR "moved to heap: i"
j := 0 // ERROR "moved to heap: j"
- m := map[*int]*int{&i: &j} // ERROR "literal escapes to heap"
- sink = m // ERROR "m escapes to heap"
+ m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} escapes to heap"
+ sink = m
}
func map9() *int {
// BAD: i should not escape
i := 0 // ERROR "moved to heap: i"
j := 0 // ERROR "moved to heap: j"
- m := map[*int]*int{&i: &j} // ERROR "literal does not escape"
+ m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} does not escape"
return m[nil]
}