1// run 2 3// Copyright 2023 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 7package main 8 9import "unsafe" 10 11//go:noinline 12func f(x []byte) bool { 13 return unsafe.SliceData(x) != nil 14} 15 16//go:noinline 17func g(x string) bool { 18 return unsafe.StringData(x) != nil 19} 20 21func main() { 22 if f(nil) { 23 panic("bad f") 24 } 25 if g("") { 26 panic("bad g") 27 } 28} 29