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
Closed

cmd/compile: regression in commit c6bf9a8109 #27829

rski opened this issue Sep 24, 2018 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rski
Copy link

rski 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
Copy link
Member

mvdan commented Sep 24, 2018

Assigning to @benshi001, the commit author.

@mvdan mvdan added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 24, 2018
@mvdan mvdan added this to the Go1.12 milestone Sep 24, 2018
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants