Source file test/fixedbugs/issue44823.go

     1  // run
     2  
     3  // Copyright 2021 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 44823: miscompilation with store combining.
     8  
     9  package main
    10  
    11  import "encoding/binary"
    12  
    13  //go:noinline
    14  func Id(a [8]byte) (x [8]byte) {
    15  	binary.LittleEndian.PutUint64(x[:], binary.LittleEndian.Uint64(a[:]))
    16  	return
    17  }
    18  
    19  var a = [8]byte{1, 2, 3, 4, 5, 6, 7, 8}
    20  
    21  func main() {
    22  	x := Id(a)
    23  	if x != a {
    24  		panic("FAIL")
    25  	}
    26  }
    27  

View as plain text