Debian Codegraph @

test/fixedbugs/issue48473.go

raw
1 // run
2
3 // Copyright 2021 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 "fmt"
10
11 func f(x uint64) uint64 {
12 s := "\x04"
13 c := s[0]
14 return x - x<<c<<4
15 }
16
17 func g(x uint32) uint32 {
18 s := "\x04"
19 c := s[0]
20 return x - x<<c<<4
21 }
22
23 func main() {
24 if want, got := uint64(0xffffffffffffff01), f(1); want != got {
25 panic(fmt.Sprintf("want %x got %x", want, got))
26 }
27 if want, got := uint32(0xffffff01), g(1); want != got {
28 panic(fmt.Sprintf("want %x got %x", want, got))
29 }
30 }