summaryrefslogtreecommitdiffstats
path: root/test/fixedbugs/issue47185.dir/bad/bad.go
blob: 1aa4fbb909522ae1409f0895e3f04c58a47d73ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package a

// Note that the use of CGO here is solely to trigger external
// linking, since that is required to trigger that bad behavior
// in this bug.

// #include <stdlib.h>
import "C"

func Bad() {
	m := make(map[int64]A)
	a := m[0]
	if len(a.B.C1.D2.E2.F1) != 0 ||
		len(a.B.C1.D2.E2.F2) != 0 ||
		len(a.B.C1.D2.E2.F3) != 0 ||
		len(a.B.C1.D2.E2.F4) != 0 ||
		len(a.B.C1.D2.E2.F5) != 0 ||
		len(a.B.C1.D2.E2.F6) != 0 ||
		len(a.B.C1.D2.E2.F7) != 0 ||
		len(a.B.C1.D2.E2.F8) != 0 ||
		len(a.B.C1.D2.E2.F9) != 0 ||
		len(a.B.C1.D2.E2.F10) != 0 ||
		len(a.B.C1.D2.E2.F11) != 0 ||
		len(a.B.C1.D2.E2.F16) != 0 {
		panic("bad")
	}
	C.malloc(100)
}

type A struct {
	B
}

type B struct {
	C1 C
	C2 C
}

type C struct {
	D1 D
	D2 D
}

type D struct {
	E1 E
	E2 E
	E3 E
	E4 E
}

type E struct {
	F1  string
	F2  string
	F3  string
	F4  string
	F5  string
	F6  string
	F7  string
	F8  string
	F9  string
	F10 string
	F11 string
	F12 string
	F13 string
	F14 string
	F15 string
	F16 string
}