Debian Codegraph @

test/fixedbugs/issue77635b.go

raw
1 // compile
2
3 // Copyright 2026 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 // Issue 77635: test building values of zero-sized types.
8
9 package p
10
11 type T1 [2][0]int
12 type T2 [0][2]int
13 type T3 struct {
14 t T1
15 x *byte
16 }
17 type T4 struct {
18 t T2
19 x *byte
20 }
21
22 func f1(t T1) any {
23 return t
24 }
25 func f2(t T2) any {
26 return t
27 }
28 func f3(t T3) any {
29 return t
30 }
31 func f4(t T4) any {
32 return t
33 }
34 func f5(t T1) any {
35 return T3{t:t}
36 }
37 func f6(t T2) any {
38 return T4{t:t}
39 }
40 func f7(t T1) {
41 use(T3{t:t})
42 }
43 func f8(t T2) {
44 use(T4{t:t})
45 }
46
47 func g1(t T3, i int) {
48 t.t[i][i] = 1
49 }
50 func g2(t T4, i int) {
51 t.t[i][i] = 1
52 }
53 func g3(t *T3, i int) {
54 t.t[i][i] = 1
55 }
56 func g4(t *T4, i int) {
57 t.t[i][i] = 1
58 }
59
60 //go:noinline
61 func use(x any) {
62 }