github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/test/fixedbugs/issue4518.go (about) 1 // run 2 3 // Copyright 2012 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 4518. In some circumstances "return F(...)" 8 // where F has multiple returns is miscompiled by 6g due to 9 // bold assumptions in componentgen. 10 11 package main 12 13 func DontInline() {} 14 15 func F(e interface{}) (int, int) { 16 DontInline() 17 return 3, 7 18 } 19 20 func G() (int, int) { 21 DontInline() 22 return 3, 7 23 } 24 25 func bogus1(d interface{}) (int, int) { 26 switch { 27 default: 28 return F(d) 29 } 30 return 0, 0 31 } 32 33 func bogus2() (int, int) { 34 switch { 35 default: 36 return F(3) 37 } 38 return 0, 0 39 } 40 41 func bogus3(d interface{}) (int, int) { 42 switch { 43 default: 44 return G() 45 } 46 return 0, 0 47 } 48 49 func bogus4() (int, int) { 50 switch { 51 default: 52 return G() 53 } 54 return 0, 0 55 } 56 57 func check(a, b int) { 58 if a != 3 || b != 7 { 59 println(a, b) 60 panic("a != 3 || b != 7") 61 } 62 } 63 64 func main() { 65 check(bogus1(42)) 66 check(bogus2()) 67 }