Source file test/fixedbugs/issue47185.dir/bad/bad.go

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package a
     6  
     7  // Note that the use of CGO here is solely to trigger external
     8  // linking, since that is required to trigger that bad behavior
     9  // in this bug.
    10  
    11  // #include <stdlib.h>
    12  import "C"
    13  
    14  func Bad() {
    15  	m := make(map[int64]A)
    16  	a := m[0]
    17  	if len(a.B.C1.D2.E2.F1) != 0 ||
    18  		len(a.B.C1.D2.E2.F2) != 0 ||
    19  		len(a.B.C1.D2.E2.F3) != 0 ||
    20  		len(a.B.C1.D2.E2.F4) != 0 ||
    21  		len(a.B.C1.D2.E2.F5) != 0 ||
    22  		len(a.B.C1.D2.E2.F6) != 0 ||
    23  		len(a.B.C1.D2.E2.F7) != 0 ||
    24  		len(a.B.C1.D2.E2.F8) != 0 ||
    25  		len(a.B.C1.D2.E2.F9) != 0 ||
    26  		len(a.B.C1.D2.E2.F10) != 0 ||
    27  		len(a.B.C1.D2.E2.F11) != 0 ||
    28  		len(a.B.C1.D2.E2.F16) != 0 {
    29  		panic("bad")
    30  	}
    31  	C.malloc(100)
    32  }
    33  
    34  type A struct {
    35  	B
    36  }
    37  
    38  type B struct {
    39  	C1 C
    40  	C2 C
    41  }
    42  
    43  type C struct {
    44  	D1 D
    45  	D2 D
    46  }
    47  
    48  type D struct {
    49  	E1 E
    50  	E2 E
    51  	E3 E
    52  	E4 E
    53  }
    54  
    55  type E struct {
    56  	F1  string
    57  	F2  string
    58  	F3  string
    59  	F4  string
    60  	F5  string
    61  	F6  string
    62  	F7  string
    63  	F8  string
    64  	F9  string
    65  	F10 string
    66  	F11 string
    67  	F12 string
    68  	F13 string
    69  	F14 string
    70  	F15 string
    71  	F16 string
    72  }
    73  

View as plain text