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// Issue 8139. The x.(T) assertions used to write 1 (unexpected) 8// return byte for the 0-byte return value T. 9 10package main 11 12import "fmt" 13 14type T struct{} 15 16func (T) M() {} 17 18type M interface { 19 M() 20} 21 22var e interface{} = T{} 23var i M = T{} 24var b bool 25 26func f1() int { 27 if b { 28 return f1() // convince inliner not to inline 29 } 30 z := 0x11223344 31 _ = e.(T) 32 return z 33} 34 35func f2() int { 36 if b { 37 return f1() // convince inliner not to inline 38 } 39 z := 0x11223344 40 _ = i.(T) 41 return z 42} 43 44func main() { 45 x := f1() 46 y := f2() 47 if x != 0x11223344 || y != 0x11223344 { 48 fmt.Printf("BUG: x=%#x y=%#x, want 0x11223344 for both\n", x, y) 49 } 50} 51