test/fixedbugs/bug199.go
raw| 1 | // run |
| 2 | |
| 3 | // Copyright 2009 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 | package main |
| 8 | |
| 9 | type S struct { |
| 10 | a []int |
| 11 | } |
| 12 | |
| 13 | var s = &S{make([]int, 10)} |
| 14 | |
| 15 | func main() { |
| 16 | s.a[f()] = 1 // 6g used to call f twice here |
| 17 | } |
| 18 | |
| 19 | var n int |
| 20 | |
| 21 | func f() int { |
| 22 | if n++; n > 1 { |
| 23 | println("f twice") |
| 24 | panic("fail") |
| 25 | } |
| 26 | return 0 |
| 27 | } |