Source file
test/fixedbugs/notinheap3.go
1
2
3
4
5
6
7
8
9
10
11 package p
12
13 import "runtime/cgo"
14
15 type t1 struct {
16 x *nih
17 s []nih
18 y [1024]byte
19 }
20
21 type t2 struct {
22 x *ih
23 s []ih
24 y [1024]byte
25 }
26
27 type nih struct {
28 _ cgo.Incomplete
29 x uintptr
30 }
31
32 type ih struct {
33 x uintptr
34 }
35
36 var (
37 v1 t1
38 v2 t2
39
40 v1s []t1
41 v2s []t2
42 )
43
44 func f() {
45
46 v1.x = nil
47 v2.x = nil
48 v1.s = []nih(nil)
49 v2.s = []ih(nil)
50 }
51
52 func g() {
53
54 v1 = t1{x: nil}
55 v2 = t2{x: nil}
56 }
57
58 func h() {
59
60 copy(v1s, v1s[1:])
61 copy(v2s, v2s[1:])
62 _ = append(v1s, v1s...)
63 _ = append(v2s, v2s...)
64 }
65
66
67
68 var (
69 sliceIH []*ih
70 sliceNIH []*nih
71 )
72
73 func sliceClear() {
74 for i := range sliceIH {
75 sliceIH[i] = nil
76 }
77 for i := range sliceNIH {
78 sliceNIH[i] = nil
79 }
80 }
81
View as plain text