Source file
test/fixedbugs/issue45242.go
1
2
3
4
5
6
7 package main
8
9 import "fmt"
10
11
12 func repro(b []byte, bit int32) {
13 _ = b[3]
14 v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 | 1<<(bit&31)
15 b[0] = byte(v)
16 b[1] = byte(v >> 8)
17 b[2] = byte(v >> 16)
18 b[3] = byte(v >> 24)
19 }
20
21 func main() {
22 var b [8]byte
23 repro(b[:], 32)
24 want := [8]byte{1, 0, 0, 0, 0, 0, 0, 0}
25 if b != want {
26 panic(fmt.Sprintf("got %v, want %v\n", b, want))
27 }
28 }
29
View as plain text