Source file test/fixedbugs/issue8612.go

     1  //compile
     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 had a bug comparing a struct or array value with an interface
     8  // values, when the struct or array was not addressable.
     9  
    10  package p
    11  
    12  type A [10]int
    13  
    14  type S struct {
    15  	i int
    16  }
    17  
    18  func F1() S {
    19  	return S{0}
    20  }
    21  
    22  func F2() A {
    23  	return A{}
    24  }
    25  
    26  func Cmp(v interface{}) bool {
    27  	if F1() == v {
    28  		return true
    29  	}
    30  	if F2() == v {
    31  		return true
    32  	}
    33  	return false
    34  }
    35  

View as plain text