Debian Codegraph @

test/fixedbugs/issue39292.go

raw
1 // errorcheck -0 -m -l
2
3 // Copyright 2020 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 package p
8
9 type t [20000]*int
10
11 func (t) f() {
12 }
13
14 func x() {
15 x := t{}.f // ERROR "t{}.f escapes to heap"
16 x()
17 }
18
19 func y() {
20 var i int // ERROR "moved to heap: i"
21 y := (&t{&i}).f // ERROR "\(&t{...}\).f escapes to heap" "&t{...} escapes to heap"
22 y()
23 }
24
25 func z() {
26 var i int // ERROR "moved to heap: i"
27 z := t{&i}.f // ERROR "t{...}.f escapes to heap"
28 z()
29 }
30
31 // Should match cmd/compile/internal/ir/cfg.go:MaxStackVarSize.
32 const maxStack = 128 * 1024
33
34 func w(i int) byte {
35 var x [maxStack]byte
36 var y [maxStack + 1]byte // ERROR "moved to heap: y"
37 return x[i] + y[i]
38 }