Debian Codegraph @

test/fixedbugs/issue43570.go

raw
1 // run
2
3 // Copyright 2021 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 package main
8
9 import "fmt"
10
11 type T [8]*int
12
13 //go:noinline
14 func f(x int) T {
15 return T{}
16 }
17
18 //go:noinline
19 func g(x int, t T) {
20 if t != (T{}) {
21 panic(fmt.Sprintf("bad: %v", t))
22 }
23 }
24
25 func main() {
26 const N = 10000
27 var q T
28 func() {
29 for i := 0; i < N; i++ {
30 q = f(0)
31 g(0, q)
32 sink = make([]byte, 1024)
33 }
34 }()
35 // Note that the closure is a trick to get the write to q to be a
36 // write to a pointer that is known to be non-nil and requires
37 // a write barrier.
38 }
39
40 var sink []byte