modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue8620.go (about)

     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 8620. Used to fail with -race.
     8  
     9  package main
    10  
    11  func min(a, b int) int {
    12  	if a < b {
    13  		return a
    14  	}
    15  	return b
    16  }
    17  
    18  func test(s1, s2 []struct{}) {
    19  	n := min(len(s1), len(s2))
    20  	if copy(s1, s2) != n {
    21  		panic("bad copy result")
    22  	}
    23  }
    24  
    25  func main() {
    26  	var b [100]struct{}
    27  	test(b[:], b[:])
    28  	test(b[1:], b[:])
    29  	test(b[:], b[2:])
    30  }