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 7package main 8 9//go:noinline 10func f(x int) { 11} 12 13//go:noinline 14func val() int8 { 15 return -1 16} 17 18var ( 19 array = [257]int{} 20 slice = array[1:] 21) 22 23func init() { 24 for i := range array { 25 array[i] = i - 1 26 } 27} 28 29func main() { 30 x := val() 31 y := int(uint8(x)) 32 f(y) // try and force y to be calculated and spilled 33 if slice[y] != 255 { 34 panic("incorrect value") 35 } 36} 37