Russ Cox | 10eb76b | 2010-04-29 15:52:27 -0700 | [diff] [blame] | 1 | // $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 | |
| 9 | package main |
| 10 | |
| 11 | type T1 struct { |
| 12 | T2 *T2 |
| 13 | } |
| 14 | |
| 15 | type T2 struct { |
| 16 | T3 *T3 |
| 17 | } |
| 18 | |
| 19 | type T3 struct { |
| 20 | T4 []*T4 |
| 21 | } |
| 22 | |
| 23 | type T4 struct { |
| 24 | X int |
| 25 | } |
| 26 | |
| 27 | func 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 | |
| 40 | func g(x int) { |
| 41 | if x == 0 { |
| 42 | return |
| 43 | } |
| 44 | g(x-1) |
| 45 | } |
| 46 | |
| 47 | func 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 | } |