Source file
test/fixedbugs/issue40954.go
1
2
3
4
5
6
7
8
9 package main
10
11 import (
12 "runtime/cgo"
13 "unsafe"
14 )
15
16 type S struct {
17 _ cgo.Incomplete
18 x int
19 }
20
21 func main() {
22 var i int
23 p := (*S)(unsafe.Pointer(uintptr(unsafe.Pointer(&i))))
24 v := uintptr(unsafe.Pointer(p))
25
26
27
28
29
30
31 recurse(100, p, v)
32 }
33
34
35 func recurse(n int, p *S, v uintptr) {
36 if n > 0 {
37 recurse(n-1, p, v)
38 }
39 if uintptr(unsafe.Pointer(p)) != v {
40 panic("adjusted notinheap pointer")
41 }
42 }
43
View as plain text