Running it on linux/arm produces incorrectly 0:
jnml@pi32:~/tmp$ cat bug.go
package main
func boolInt32(b bool) int32 {
if b {
return 1
}
return 0
}
func f(left uint16, right int32) (r uint16) {
return left >> right
}
var n = uint16(65535)
func main() {
println(f(n, boolInt32(int64(n^n) > 1)))
}
jnml@pi32:~/tmp$ go run bug.go
0
jnml@pi32:~/tmp$ go version
go version go1.21.5 linux/arm
jnml@pi32:~/tmp$ csmith --version
csmith 2.3.0
Git version: 30dccd7
jnml@pi32:~/tmp$
Found by ccgo/v4/lib tests via comparing gcc results and Go results[0]. Minimized, mostly.
I was not able to verify if the issue is fixed at tip:
jnml@pi32:~/tmp$ go install golang.org/dl/gotip@latest
go: downloading golang.org/dl v0.0.0-20231205181335-d8bde1699968
jnml@pi32:~/tmp$ gotip download
Cloning into '/home/jnml/sdk/gotip'...
remote: Finding sources: 100% (13954/13954)
remote: Total 13954 (delta 2000), reused 9023 (delta 2000)
Receiving objects: 100% (13954/13954), 28.49 MiB | 8.73 MiB/s, done.
Resolving deltas: 100% (2000/2000), done.
Updating files: 100% (12839/12839), done.
Updating the go development tree...
From https://go.googlesource.com/go
* branch master -> FETCH_HEAD
HEAD is now at d1a186d doc: add release note fragment on inlining changes
Building Go cmd/dist using /usr/local/go. (go1.21.5 linux/arm)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/arm64.
# runtime/cgo
In file included from _cgo_export.c:4:
cgo-gcc-export-header-prolog:31:14: error: size of array ‘_check_for_64_bit_pointer_matching_GoInt’ is negative
go tool dist: FAILED: /home/jnml/sdk/gotip/pkg/tool/linux_arm64/go_bootstrap install std: exit status 1
gotip: failed to build go: exit status 2
jnml@pi32:~/tmp$
PS: No Github account here.
----