Source file test/fixedbugs/issue61187.go
1 // compile 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 7 package main 8 9 import ( 10 "fmt" 11 "reflect" 12 "unsafe" 13 ) 14 15 var slice = []byte{'H', 'e', 'l', 'l', 'o', ','} 16 17 func main() { 18 ptr := uintptr(unsafe.Pointer(&slice)) + 100 19 header := (*reflect.SliceHeader)(unsafe.Pointer(ptr)) 20 header.Data += 1 21 fmt.Printf("%d %d\n", cap(slice), header.Cap) 22 } 23