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

gccgo: value comparison with interface is broken #40152

Closed
zhsj opened this issue Jul 10, 2020 · 3 comments
Closed

gccgo: value comparison with interface is broken #40152

zhsj opened this issue Jul 10, 2020 · 3 comments
Assignees
Milestone

Comments

@zhsj
Copy link

@zhsj zhsj commented Jul 10, 2020

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

$ go version
go version go1.14.2 gccgo (Debian 20200616-1) 11.0.0 20200616 (experimental) [master revision beaf12b49ae:aed76232726:b70eeb248efe2b3e9bdb5e26b490e3d8aa07022d] linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zhsj/.cache/go-build"
GOENV="/home/zhsj/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zhsj/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io"
GOROOT="/usr"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/gcc/x86_64-linux-gnu/10"
GCCGO="/usr/lib/gcc-snapshot/bin/gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build551180179=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

package main

import (
        "fmt"
)

func t(args ...interface{}) bool {
        x := true
        return x == args[0]
}

func main() {
        fmt.Println(t("x" == "x" && "y" == "y"))
}

What did you expect to see?

same as gc, print "true"

What did you see instead?

print "false"

@gopherbot gopherbot added this to the Gccgo milestone Jul 10, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jul 10, 2020

Change https://golang.org/cl/242000 mentions this issue: test: add test for conversion of untyped bool to interface

@ianlancetaylor ianlancetaylor self-assigned this Jul 10, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jul 10, 2020

Change https://golang.org/cl/242002 mentions this issue: compiler: avoid generating unnamed bool type descriptor

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 11, 2020

Thanks for reporting this bug. It is now fixed on GCC trunk.

kraj pushed a commit to kraj/gcc that referenced this issue Jul 11, 2020
We were generating it in cases where a boolean expression was
converted directly to an empty interface type.

Fixes golang/go#40152

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/242002
gopherbot pushed a commit that referenced this issue Aug 15, 2020
gccgo miscompiled this case.

Updates #40152

Change-Id: I8448c155e802e39d8fc7cda4930ce62cb6363ce5
Reviewed-on: https://go-review.googlesource.com/c/go/+/242000
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.