modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/bug199.go (about) 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 }