1// run
2
3// Copyright 2018 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// Issue 26248: gccgo miscompiles interface field expression.
8// In G().M where G returns an interface, G() is evaluated twice.
9
10package main
11
12type I interface {
13	M()
14}
15
16type T struct{}
17
18func (T) M() {}
19
20var g = 0
21
22//go:noinline
23func G() I {
24	g++
25	return T{}
26}
27
28//go:noinline
29func Use(interface{}) {}
30
31func main() {
32	x := G().M
33	Use(x)
34
35	if g != 1 {
36		println("want 1, got", g)
37		panic("FAIL")
38	}
39}
40