Index: test/escape2.go =================================================================== --- a/test/escape2.go +++ b/test/escape2.go @@ -1065,3 +1065,34 @@ goto L1 _ = i } + +func foo124(x **int) { // ERROR "does not escape" + var i int // ERROR "moved to heap" + p := &i // ERROR "&i escapes" + func() { // ERROR "does not escape" + *x = p // ERROR "leaking closure reference" + }() +} + +func foo125(ch chan *int) { // ERROR "does not escape" + var i int // ERROR "moved to heap" + p := &i // ERROR "&i escapes" + func() { // ERROR "does not escape" + ch <- p // ERROR "leaking closure reference" + }() +} + +func foo126() { + var px *int // loopdepth 0 + for { + // loopdepth 1 + var i int // ERROR "moved to heap" + // px = &i // would escape i-> should move to heap, as should the one below + func() { // ERROR "func literal does not escape" + px = &i // ERROR "&i escapes" + }() + } + +} + +