// unsafe.Slice(ptr *T, len IntegerType) []T
check.verifyVersionf(call.Fun, go1_17, "unsafe.Slice")
- ptr, _ := under(x.typ).(*Pointer) // TODO(gri) should this be coreType rather than under?
+ ptr, _ := coreType(x.typ).(*Pointer)
if ptr == nil {
check.errorf(x, InvalidUnsafeSlice, invalidArg+"%s is not a pointer", x)
return
// unsafe.SliceData(slice []T) *T
check.verifyVersionf(call.Fun, go1_20, "unsafe.SliceData")
- slice, _ := under(x.typ).(*Slice) // TODO(gri) should this be coreType rather than under?
+ slice, _ := coreType(x.typ).(*Slice)
if slice == nil {
check.errorf(x, InvalidUnsafeSliceData, invalidArg+"%s is not a slice", x)
return
// unsafe.Slice(ptr *T, len IntegerType) []T
check.verifyVersionf(call.Fun, go1_17, "unsafe.Slice")
- ptr, _ := under(x.typ).(*Pointer) // TODO(gri) should this be coreType rather than under?
+ ptr, _ := coreType(x.typ).(*Pointer)
if ptr == nil {
check.errorf(x, InvalidUnsafeSlice, invalidArg+"%s is not a pointer", x)
return
// unsafe.SliceData(slice []T) *T
check.verifyVersionf(call.Fun, go1_20, "unsafe.SliceData")
- slice, _ := under(x.typ).(*Slice) // TODO(gri) should this be coreType rather than under?
+ slice, _ := coreType(x.typ).(*Slice)
if slice == nil {
check.errorf(x, InvalidUnsafeSliceData, invalidArg+"%s is not a slice", x)
return
--- /dev/null
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package issue64406
+
+import (
+ "unsafe"
+)
+
+func sliceData[E any, S ~[]E](s S) *E {
+ return unsafe.SliceData(s)
+}
+
+func slice[E any, S ~*E](s S) []E {
+ return unsafe.Slice(s, 0)
+}
+
+func f() {
+ s := []uint32{0}
+ _ = sliceData(s)
+ _ = slice(&s)
+}