modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/bug444.go (about) 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 11 package main 12 13 import "reflect" 14 15 type T interface {} 16 17 var x bool 18 19 func main() { 20 reflect.TypeOf(nil) 21 reflect.TypeOf(T(nil)) // used to miscompile 22 shouldPanic() 23 } 24 25 func f() byte { 26 return []byte(nil)[0] // used to miscompile 27 } 28 29 func shouldPanic() { 30 defer func() { 31 if recover() == nil { 32 panic("not panicking") 33 } 34 }() 35 f() 36 }