src/internal/types/testdata/fixedbugs/issue64406.go
raw| 1 | // Copyright 2023 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 issue64406 |
| 6 | |
| 7 | import ( |
| 8 | "unsafe" |
| 9 | ) |
| 10 | |
| 11 | func sliceData[E any, S ~[]E](s S) *E { |
| 12 | return unsafe.SliceData(s) |
| 13 | } |
| 14 | |
| 15 | func slice[E any, S ~*E](s S) []E { |
| 16 | return unsafe.Slice(s, 0) |
| 17 | } |
| 18 | |
| 19 | func f() { |
| 20 | s := []uint32{0} |
| 21 | _ = sliceData(s) |
| 22 | _ = slice(&s) |
| 23 | } |