1 // Copyright 2020 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.
12 // Explicitly allocating a variable of type reflect.SliceHeader.
13 func _(p *byte, n int) []byte {
14 var sh reflect.SliceHeader
15 sh.Data = uintptr(unsafe.Pointer(p))
18 return *(*[]byte)(unsafe.Pointer(&sh)) // want "possible misuse of reflect.SliceHeader"
21 // Implicitly allocating a variable of type reflect.SliceHeader.
22 func _(p *byte, n int) []byte {
23 return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ // want "possible misuse of reflect.SliceHeader"
24 Data: uintptr(unsafe.Pointer(p)),
30 // Use reflect.StringHeader as a composite literal value.
31 func _(p *byte, n int) []byte {
33 *(*reflect.StringHeader)(unsafe.Pointer(&res)) = reflect.StringHeader{ // want "possible misuse of reflect.StringHeader"
34 Data: uintptr(unsafe.Pointer(p)),
41 // don't crash when obj.Pkg() == nil