1// run 2 3// Copyright 2012 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// The no-op conversion here used to confuse the compiler 8// into doing a load-effective-address of nil. 9// See issue 3670. 10 11package main 12 13import "reflect" 14 15type T interface {} 16 17var x bool 18 19func main() { 20 reflect.TypeOf(nil) 21 reflect.TypeOf(T(nil)) // used to miscompile 22 shouldPanic() 23} 24 25func f() byte { 26 return []byte(nil)[0] // used to miscompile 27} 28 29func shouldPanic() { 30 defer func() { 31 if recover() == nil { 32 panic("not panicking") 33 } 34 }() 35 f() 36} 37