blob: a38d0545b1d1506ecdb3668786d24974fbe8234e [file] [log] [blame]
Russ Cox10eb76b2010-04-29 15:52:27 -07001// $G $D/$F.go && $L $F.$A && ./$A.out
2
3// Copyright 2010 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// http://code.google.com/p/go/issues/detail?id=745
8
9package main
10
11type T1 struct {
12 T2 *T2
13}
14
15type T2 struct {
16 T3 *T3
17}
18
19type T3 struct {
20 T4 []*T4
21}
22
23type T4 struct {
24 X int
25}
26
27func f() *T1 {
28 x := &T1{
29 &T2{
30 &T3{
31 [1]*T4{
32 &T4{5},
33 }[0:],
34 },
35 },
36 }
37 return x
38}
39
40func g(x int) {
41 if x == 0 {
42 return
43 }
44 g(x-1)
45}
46
47func main() {
48 x := f()
49 g(100) // smash temporaries left over on stack
50 if x.T2.T3.T4[0].X != 5 {
51 println("BUG", x.T2.T3.T4[0].X)
52 }
53}