src/runtime/race/testdata/issue12225_test.go
raw| 1 | // Copyright 2015 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package race_test |
| 6 | |
| 7 | import "unsafe" |
| 8 | |
| 9 | // golang.org/issue/12225 |
| 10 | // The test is that this compiles at all. |
| 11 | |
| 12 | //go:noinline |
| 13 | func convert(s string) []byte { |
| 14 | return []byte(s) |
| 15 | } |
| 16 | |
| 17 | func issue12225() { |
| 18 | println(*(*int)(unsafe.Pointer(&convert("")[0]))) |
| 19 | println(*(*int)(unsafe.Pointer(&[]byte("")[0]))) |
| 20 | } |