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 func recurse(n int, p *S, v uintptr) {
34 if n > 0 {
35 recurse(n-1, p, v)
36 }
37 if uintptr(unsafe.Pointer(p)) != v {
38 panic("adjusted notinheap pointer")
39 }
40 }
41
View as plain text