Russ Cox | 2b1c9b4 | 2012-02-16 23:49:30 -0500 | [diff] [blame] | 1 | // run |
Russ Cox | 6e8524b | 2009-08-30 18:47:48 -0700 | [diff] [blame] | 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 { |
Rob Pike | 325cf8e | 2010-03-24 16:46:53 -0700 | [diff] [blame] | 10 | a []int |
Russ Cox | 6e8524b | 2009-08-30 18:47:48 -0700 | [diff] [blame] | 11 | } |
Rob Pike | 325cf8e | 2010-03-24 16:46:53 -0700 | [diff] [blame] | 12 | |
Russ Cox | 6e8524b | 2009-08-30 18:47:48 -0700 | [diff] [blame] | 13 | var s = &S{make([]int, 10)} |
| 14 | |
| 15 | func main() { |
Rob Pike | 325cf8e | 2010-03-24 16:46:53 -0700 | [diff] [blame] | 16 | s.a[f()] = 1 // 6g used to call f twice here |
Russ Cox | 6e8524b | 2009-08-30 18:47:48 -0700 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | var n int |
Rob Pike | 325cf8e | 2010-03-24 16:46:53 -0700 | [diff] [blame] | 20 | |
| 21 | func f() int { |
Russ Cox | 6e8524b | 2009-08-30 18:47:48 -0700 | [diff] [blame] | 22 | if n++; n > 1 { |
Rob Pike | 325cf8e | 2010-03-24 16:46:53 -0700 | [diff] [blame] | 23 | println("f twice") |
| 24 | panic("fail") |
Russ Cox | 6e8524b | 2009-08-30 18:47:48 -0700 | [diff] [blame] | 25 | } |
| 26 | return 0 |
| 27 | } |