Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: regression in commit c6bf9a8109 #27829

Closed
rski opened this issue Sep 24, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@rski
Copy link

commented Sep 24, 2018

What version of Go are you using (go version)?

$ ../bin/go version
go version devel +ce536837d8 Sun Sep 23 19:59:57 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

No, only present in master

What operating system and processor architecture are you using (go env)?

$  ../bin/go env    
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/rski/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/rski/go"
GOPROXY=""
GORACE=""
GOROOT="/home/rski/Code/go"
GOTMPDIR=""
GOTOOLDIR="/home/rski/Code/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build909293570=/tmp/go-build -gno-record-gcc-switches"
const mask = 0x4000

func TestGoRegression(t *testing.T) {
	value := uint64(100000000000000000)
	fmt.Println((value >> 48) & (^uint64(mask)))
	foo(value)
}

func foo(value uint64) {
	fmt.Println((value >> 48) & (^uint64(mask)))
}
 /home/rski/Code/go/bin/go test -run "TestGoRegression" ./... -v -count=1
=== RUN   TestGoRegression
355
0

However, this does the right thing:

const mask = 0x4000

func TestGoRegression(t *testing.T) {
	value := uint64(100000000000000000)
	fmt.Println((value >> 48) & (^uint64(mask)))
	fmt.Println(foo(value))
}

func foo(value uint64) uint64 {
	return ((value >> 48) & (^uint64(mask)))
}
 /home/rski/Code/go/bin/go test -run "TestGoRegression" ./... -v -count=1
=== RUN   TestGoRegression
355
355
@mvdan

This comment has been minimized.

Copy link
Member

commented Sep 24, 2018

Assigning to @benshi001, the commit author.

@mvdan mvdan added this to the Go1.12 milestone Sep 24, 2018

@gopherbot

This comment has been minimized.

Copy link

commented Sep 24, 2018

Change https://golang.org/cl/136899 mentions this issue: cmd/compile: &^ and << have equal precedence

@gopherbot gopherbot closed this in 9774fa6 Sep 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.