modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue4099.go (about) 1 // errorcheck -0 -m 2 3 // Copyright 2013 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Check go:noescape annotations. 8 9 package p 10 11 // The noescape comment only applies to the next func, 12 // which must not have a body. 13 14 //go:noescape 15 16 func F1([]byte) 17 18 func F2([]byte) 19 20 func G() { 21 var buf1 [10]byte 22 F1(buf1[:]) // ERROR "buf1 does not escape" 23 24 var buf2 [10]byte // ERROR "moved to heap: buf2" 25 F2(buf2[:]) // ERROR "buf2 escapes to heap" 26 }