diff options
author | Keith Randall <khr@golang.org> | 2020-05-04 09:50:20 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2020-05-05 15:41:37 +0000 |
commit | b4ecafc986268d171776603537d40c8dff3fae61 (patch) | |
tree | aa94738242e4826690adbceefab68683a251d98d /test | |
parent | 9b189686a53d7fec7deb93d7521531157aa023cb (diff) | |
download | go-b4ecafc986268d171776603537d40c8dff3fae61.tar.gz go-b4ecafc986268d171776603537d40c8dff3fae61.zip |
cmd/compile: restrict bit test rewrite rules
The {AND,OR,XOR}const ops can only take an int32 as an argument.
Make sure that when rewriting a BTx op to one of these, the result
has no high-order bits.
Fixes #38746
Change-Id: Ia7c5f76952329f60974bc033c29a5433610f3b28
Reviewed-on: https://go-review.googlesource.com/c/go/+/231977
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixedbugs/issue38746.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/fixedbugs/issue38746.go b/test/fixedbugs/issue38746.go new file mode 100644 index 0000000000..c670349ed4 --- /dev/null +++ b/test/fixedbugs/issue38746.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2020 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 + +var g *uint64 + +func main() { + var v uint64 + g = &v + v &^= (1 << 31) + v |= 1 << 63 + v &^= (1 << 63) +} |