Source file
test/fixedbugs/issue46938.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "strings"
11 "unsafe"
12 )
13
14 func main() {
15 defer func() {
16 err := recover()
17 if err == nil {
18 panic("expected panic")
19 }
20 if got := err.(error).Error(); !strings.Contains(got, "slice bounds out of range") {
21 panic("expected panic slice out of bound, got " + got)
22 }
23 }()
24 s := make([]int64, 100)
25 p := unsafe.Pointer(&s[0])
26 n := 1000
27
28 _ = (*[10]int64)(p)[:n:n]
29 }
30
View as plain text