Source file test/fixedbugs/issue21963.go

     1  // run
     2  
     3  // Copyright 2017 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  import (
    10  	"fmt"
    11  	"runtime"
    12  )
    13  
    14  //go:noinline
    15  func f(x []int32, y *int8) int32 {
    16  	c := int32(int16(*y))
    17  	runtime.GC()
    18  	return x[0] * c
    19  }
    20  
    21  func main() {
    22  	var x = [1]int32{5}
    23  	var y int8 = -1
    24  	if got, want := f(x[:], &y), int32(-5); got != want {
    25  		panic(fmt.Sprintf("wanted %d, got %d", want, got))
    26  	}
    27  }
    28  

View as plain text