Source file test/fixedbugs/issue55122.go

     1  // run
     2  
     3  // Copyright 2022 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  package main
     8  
     9  func main() {
    10  	for i := 0; i < 10000; i++ {
    11  		h(i)
    12  		sink = make([]byte, 1024) // generate some garbage
    13  	}
    14  }
    15  
    16  func h(iter int) {
    17  	var x [32]byte
    18  	for i := 0; i < 32; i++ {
    19  		x[i] = 99
    20  	}
    21  	g(&x)
    22  	if x == ([32]byte{}) {
    23  		return
    24  	}
    25  	for i := 0; i < 32; i++ {
    26  		println(x[i])
    27  	}
    28  	panic(iter)
    29  }
    30  
    31  //go:noinline
    32  func g(x interface{}) {
    33  	switch e := x.(type) {
    34  	case *[32]byte:
    35  		var c [32]byte
    36  		*e = c
    37  	case *[]byte:
    38  		*e = nil
    39  	}
    40  }
    41  
    42  var sink []byte
    43  

View as plain text