Possible bug report

289 views
Skip to first unread message

Jan Mercl

unread,
Dec 14, 2023, 10:18:18 AM12/14/23
to golang-dev
This program

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)))
}

outputs correctly 65535 in the playground: https://go.dev/play/p/YV8FQtzCOfq

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.

---- 





Than McIntosh

unread,
Dec 14, 2023, 10:51:38 AM12/14/23
to Jan Mercl, golang-dev
Hi,

Thanks for the report.

I verified that the bug is still present on tip. 

>PS: No Github account here.

I will go ahead and submit an issue on your behalf, hope that is ok.

Cheers, Than

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/CAA40n-WoVrPQ3LvOAHaVXy3Tdb-mG8bFrMNCQ9FP36uh6pBbkQ%40mail.gmail.com.

Jan Mercl

unread,
Dec 14, 2023, 10:53:42 AM12/14/23
to Than McIntosh, golang-dev
Hi,

On Thu, Dec 14, 2023 at 4:51 PM Than McIntosh <th...@google.com> wrote:

> I will go ahead and submit an issue on your behalf, hope that is ok.

Of course it is ok, thanks a lot.

-j

Than McIntosh

unread,
Dec 14, 2023, 10:59:43 AM12/14/23
to Jan Mercl, golang-dev
Reply all
Reply to author
Forward
0 new messages