Source file src/cmd/link/testdata/testHashedSyms/p.go

     1  // Copyright 2020 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This test case contains two static temps (the array literals)
     6  // with same contents but different sizes. The linker should not
     7  // report a hash collision. The linker can (and actually does)
     8  // dedup the two symbols, by keeping the larger symbol. The dedup
     9  // is not a requirement for correctness and not checked in this test.
    10  // We do check the emitted symbol contents are correct, though.
    11  
    12  package main
    13  
    14  func main() {
    15  	F([10]int{1, 2, 3, 4, 5, 6}, [20]int{1, 2, 3, 4, 5, 6})
    16  }
    17  
    18  //go:noinline
    19  func F(x, y interface{}) {
    20  	x1 := x.([10]int)
    21  	y1 := y.([20]int)
    22  	for i := range y1 {
    23  		if i < 6 {
    24  			if x1[i] != i+1 || y1[i] != i+1 {
    25  				panic("FAIL")
    26  			}
    27  		} else {
    28  			if (i < len(x1) && x1[i] != 0) || y1[i] != 0 {
    29  				panic("FAIL")
    30  			}
    31  		}
    32  	}
    33  }
    34  

View as plain text