2009-08-30 19:47:48 -06:00
|
|
|
// $G $D/$F.go && $L $F.$A && ./$A.out
|
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
type S struct {
|
2010-03-24 17:46:53 -06:00
|
|
|
a []int
|
2009-08-30 19:47:48 -06:00
|
|
|
}
|
2010-03-24 17:46:53 -06:00
|
|
|
|
2009-08-30 19:47:48 -06:00
|
|
|
var s = &S{make([]int, 10)}
|
|
|
|
|
|
|
|
func main() {
|
2010-03-24 17:46:53 -06:00
|
|
|
s.a[f()] = 1 // 6g used to call f twice here
|
2009-08-30 19:47:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
var n int
|
2010-03-24 17:46:53 -06:00
|
|
|
|
|
|
|
func f() int {
|
2009-08-30 19:47:48 -06:00
|
|
|
if n++; n > 1 {
|
2010-03-24 17:46:53 -06:00
|
|
|
println("f twice")
|
|
|
|
panic("fail")
|
2009-08-30 19:47:48 -06:00
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|