| 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 |
|
| 11 |
package main |
| 12 |
|
| 13 |
type MyInt int |
| 14 |
|
| 15 |
var c MyInt |
| 16 |
|
| 17 |
func (c *MyInt) S(i int) { |
| 18 |
*c = MyInt(i) |
| 19 |
} |
| 20 |
|
| 21 |
func (c *MyInt) V() int { |
| 22 |
return int(*c) |
| 23 |
} |
| 24 |
|
| 25 |
type i1 interface { |
| 26 |
S(int) |
| 27 |
V() int |
| 28 |
} |
| 29 |
|
| 30 |
type i2 interface { |
| 31 |
V() int |
| 32 |
} |
| 33 |
|
| 34 |
type s struct { |
| 35 |
i i2 |
| 36 |
} |
| 37 |
|
| 38 |
func f() i1 { |
| 39 |
c++ |
| 40 |
return &c |
| 41 |
} |
| 42 |
|
| 43 |
func 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 |
} |