We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 52d9ce8 commit ff3ae45Copy full SHA for ff3ae45
test/escape_selfassign.go
@@ -0,0 +1,32 @@
1
+// errorcheck -0 -m -l
2
+
3
+// Copyright 2019 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
+// Test escape analysis for self assignments.
8
9
+package escape
10
11
+type S struct {
12
+ i int
13
+ pi *int
14
+}
15
16
+var sink S
17
18
+func f(p *S) { // ERROR "leaking param: p"
19
+ p.pi = &p.i
20
+ sink = *p
21
22
23
+// BAD: "leaking param: p" is too conservative
24
+func g(p *S) { // ERROR "leaking param: p"
25
26
27
28
+func h() {
29
+ var s S // ERROR "moved to heap: s"
30
+ g(&s)
31
+ sink = s
32
0 commit comments