aboutsummaryrefslogtreecommitdiff
path: root/test/fixedbugs/issue23812.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2018-07-02 17:50:42 -0400
committerFilippo Valsorda <filippo@golang.org>2018-07-02 22:36:31 +0000
commit0bad1bef406e987b7b749efc3bb7ab5d08b36a1c (patch)
tree34b9f97d1683622d58605928e4d75fb4df711ae5 /test/fixedbugs/issue23812.go
parent3959ce667657defe1c99984adde93ca496953765 (diff)
parent7df09b4a03f9e53334672674ba7983d5e7128646 (diff)
downloadgo-0bad1bef406e987b7b749efc3bb7ab5d08b36a1c.tar.gz
go-0bad1bef406e987b7b749efc3bb7ab5d08b36a1c.zip
[dev.boringcrypto.go1.9] all: merge go1.9.7 into dev.boringcrypto.go1.9dev.boringcrypto.go1.9
Change-Id: I1f9769a0c2c7c090886afa31c86c403da29d2013
Diffstat (limited to 'test/fixedbugs/issue23812.go')
-rw-r--r--test/fixedbugs/issue23812.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/fixedbugs/issue23812.go b/test/fixedbugs/issue23812.go
new file mode 100644
index 0000000000..0a40deb212
--- /dev/null
+++ b/test/fixedbugs/issue23812.go
@@ -0,0 +1,34 @@
+// run
+
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "fmt"
+
+func main() {
+ want := int32(0x3edae8)
+ got := foo(1)
+ if want != got {
+ panic(fmt.Sprintf("want %x, got %x", want, got))
+ }
+}
+
+func foo(a int32) int32 {
+ return shr1(int32(shr2(int64(0x14ff6e2207db5d1f), int(a))), 4)
+}
+
+func shr1(n int32, m int) int32 { return n >> uint(m) }
+
+func shr2(n int64, m int) int64 {
+ if m < 0 {
+ m = -m
+ }
+ if m >= 64 {
+ return n
+ }
+
+ return n >> uint(m)
+}