| 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 |
} |