1// run 2 3// Copyright 2013 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// Used to be miscompiled by gccgo, due to a bug in handling 8// initialization ordering. 9 10package main 11 12func F(a ...interface{}) interface{} { 13 s := 0 14 for _, v := range a { 15 s += v.(int) 16 } 17 return s 18} 19 20var V1 = F(V10, V4, V3, V11) 21 22var V2 = F(V1) 23 24var V3 = F(1) 25 26var V4 = F(2) 27 28var V5 = F(3) 29 30var V6 = F(4) 31 32var V7 = F(5) 33 34var V8 = F(V14, V7, V3, V6, V5) 35 36var V9 = F(V4, F(V12)) 37 38var V10 = F(V4, V9) 39 40var V11 = F(6) 41 42var V12 = F(V5, V3, V8) 43 44var V13 = F(7) 45 46var V14 = F(8) 47 48func expect(name string, a interface{}, b int) { 49 if a.(int) != b { 50 panic(name) 51 } 52} 53 54func main() { 55 expect("V1", V1, 38) 56 expect("V2", V2, 38) 57 expect("V3", V3, 1) 58 expect("V4", V4, 2) 59 expect("V5", V5, 3) 60 expect("V6", V6, 4) 61 expect("V7", V7, 5) 62 expect("V8", V8, 21) 63 expect("V9", V9, 27) 64 expect("V10", V10, 29) 65 expect("V11", V11, 6) 66 expect("V12", V12, 25) 67 expect("V13", V13, 7) 68 expect("V14", V14, 8) 69} 70