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: unexpected amd64 error #32701

Closed
beenshi opened this issue Jun 20, 2019 · 6 comments
Closed

cmd/compile: unexpected amd64 error #32701

beenshi opened this issue Jun 20, 2019 · 6 comments

Comments

@beenshi
Copy link

@beenshi beenshi commented Jun 20, 2019

Some simple code went wrong (only) on amd64.

The following go code

func main() {
	b := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
	temp := make([]byte, 4)
	for i := int64(0);i<4; i ++ {
		temp[0] = b[i*4 + 2]
		temp[1] = b[i*4 + 3]
		temp[2] = b[i*4 + 0]
		temp[3] = b[i*4 + 1]
		n := binary.BigEndian.Uint32(temp)
		fmt.Printf("%x\n", n)
	}
}

is expected to print

3040102
7080506
b0c090a
f100d0e

That is true on arm/arm64/386, but false on amd64.

apuser@tj07598pcu:~/Desktop$ GOARCH=arm go run main.go 
3040102
7080506
b0c090a
f100d0e
apuser@tj07598pcu:~/Desktop$ GOARCH=386 go run main.go 
3040102
7080506
b0c090a
f100d0e
apuser@tj07598pcu:~/Desktop$ GOARCH=amd64 go run main.go 
3040000
7080102
b0c0506
f10090a
apuser@tj07598pcu:~/Desktop$ GOARCH=arm64 go run main.go 
3040102
7080506
b0c090a	
f100d0e
apuser@tj07598pcu:~/Desktop$ go version
go version devel +71a6a44428 Wed Jun 19 23:17:25 2019 +0000 linux/amd64
@zboya

This comment has been minimized.

Copy link

@zboya zboya commented Jun 20, 2019

the same code!

go version
go version go1.12.5 darwin/amd64

go run main.go              
3040000
7080102
b0c0506
f10090a

go run -gcflags '-N' main.go
3040102
7080506
b0c090a
f100d0e
@av86743

This comment has been minimized.

Copy link

@av86743 av86743 commented Jun 20, 2019

@beenshi: What do you use to run arm/arm64 transparently on linux/amd64?

That is true on arm/arm64/386, but false on amd64.

apuser@tj07598pcu:~/Desktop$ GOARCH=arm go run main.go 
3040102
7080506
b0c090a
f100d0e
apuser@tj07598pcu:~/Desktop$ GOARCH=386 go run main.go 
3040102
7080506
b0c090a
f100d0e
apuser@tj07598pcu:~/Desktop$ GOARCH=amd64 go run main.go 
3040000
7080102
b0c0506
f10090a
apuser@tj07598pcu:~/Desktop$ GOARCH=arm64 go run main.go 
3040102
7080506
b0c090a	
f100d0e
apuser@tj07598pcu:~/Desktop$ go version
go version devel +71a6a44428 Wed Jun 19 23:17:25 2019 +0000 linux/amd64
@beenshi

This comment has been minimized.

Copy link
Author

@beenshi beenshi commented Jun 20, 2019

@av86743

ubuntu 18.04
apt-get install qemu -y

@cherrymui

This comment has been minimized.

Copy link
Contributor

@cherrymui cherrymui commented Jun 20, 2019

Seems a dup of #32680?

@cherrymui

This comment has been minimized.

Copy link
Contributor

@cherrymui cherrymui commented Jun 20, 2019

@dr2chase

This comment has been minimized.

Copy link
Contributor

@dr2chase dr2chase commented Jun 20, 2019

Dupe of #32680. (It at least shares the same fix.)

@dr2chase dr2chase closed this Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.