Source file
test/abi/part_live_2.go
1
2
3
4
5
6
7
8
9 package main
10
11 import "runtime"
12 import "unsafe"
13
14
15 func F(s []int) {
16 for i, x := range s {
17 G(i, x)
18 }
19 GC()
20 H(&s[0])
21 G(len(s), cap(s))
22 GC()
23 }
24
25
26
27 func G(int, int) {}
28
29
30
31 func H(*int) {}
32
33
34 func GC() { runtime.GC(); runtime.GC() }
35
36 func main() {
37 s := make([]int, 3)
38 escape(s)
39 p := int(uintptr(unsafe.Pointer(&s[2])) + 42)
40 poison([3]int{p, p, p})
41 F(s)
42 }
43
44
45
46 func poison([3]int) {}
47
48
49
50 func escape(s []int) {
51 g = s
52 }
53 var g []int
54
View as plain text