Source file test/fixedbugs/issue15902.go

     1  // run
     2  
     3  // Copyright 2016 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  // This test makes sure we don't use 4-byte unaligned writes
     8  // to zero memory on architectures that don't support them.
     9  
    10  package main
    11  
    12  type T struct {
    13  	a byte
    14  	b [10]byte
    15  }
    16  
    17  //go:noinline
    18  func f(t *T) {
    19  	// t will be aligned, so &t.b won't be.
    20  	t.b = [10]byte{}
    21  }
    22  
    23  var t T
    24  
    25  func main() {
    26  	f(&t)
    27  }
    28  

View as plain text