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 9var a uint8 10 11//go:noinline 12func f() { 13 b := int8(func() int32 { return -1 }()) 14 a = uint8(b) 15 if int32(a) != 255 { 16 // Failing case prints 'got 255 expected 255' 17 println("got", a, "expected 255") 18 } 19} 20 21//go:noinline 22func g() { 23 b := int8(func() uint32 { return 0xffffffff }()) 24 a = uint8(b) 25 if int32(a) != 255 { 26 // Failing case prints 'got 255 expected 255' 27 println("got", a, "expected 255") 28 } 29} 30 31func main() { 32 f() 33 g() 34} 35