1// run
2
3// Copyright 2014 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// Gccgo incorrectly executed functions multiple times when they
8// appeared in a composite literal that required a conversion between
9// different interface types.
10
11package main
12
13type MyInt int
14
15var c MyInt
16
17func (c *MyInt) S(i int) {
18	*c = MyInt(i)
19}
20
21func (c *MyInt) V() int {
22	return int(*c)
23}
24
25type i1 interface {
26	S(int)
27	V() int
28}
29
30type i2 interface {
31	V() int
32}
33
34type s struct {
35	i i2
36}
37
38func f() i1 {
39	c++
40	return &c
41}
42
43func main() {
44	p := &s{f()}
45	if v := p.i.V(); v != 1 {
46		panic(v)
47	}
48	if c != 1 {
49		panic(c)
50	}
51}
52