We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
$ go version go version go1.18.2 linux/amd64
Yes, tested on GCC 12.
go env
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/melonedo/.cache/go-build" GOENV="/home/melonedo/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/melonedo/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/melonedo/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18.2" GCCGO="/usr/bin/gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/melonedo/fuzzTest/go.mod" GOWORK="" 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-build557955963=/tmp/go-build -gno-record-gcc-switches"
Run go run -compiler gccgo issue.go on code:
go run -compiler gccgo issue.go
// MWE from signature fuzzer package main import "fmt" type StructF11S1 struct { _ int16 F1 int16 } //go:noinline func compare(a *StructF11S1, b *StructF11S1) bool { return *a == *b } func main() { a := StructF11S1{1, 2} fmt.Println(compare(&a, &a)) }
true should be printed.
true
false is printed.
false
Run gccgo -issue.go -fgo-dump-ast, we can find that *a and *b are not referenced at all:
gccgo -issue.go -fgo-dump-ast
.main.compare(.main.a (g._2main_0StructF11S1),.main.b (g._2main_0StructF11S1)) (.main.$ret0 (bool)) : (g.func_8_2main_0StructF11S1_3_2main_0StructF11S1_9_8bool_9) { tmp.66002704 (main.StructF11S1) // struct-equal2.go:12 tmp.66089344 (main.StructF11S1) // struct-equal2.go:12 { { tmp.66109760 (bool) = true // struct-equal2.go:12 if tmp.66109760 // struct-equal2.go:12 { tmp.66109760 = (tmp.66002704.1 == tmp.66089344.1) // struct-equal2.go:12 } } tmp.65273920 = tmp.66109760 // struct-equal2.go:12 $ret0 = tmp.65273920 // struct-equal2.go:12 return // struct-equal2.go:12 } }
A fix has been proposed at https://go-review.googlesource.com/c/gofrontend/+/431736.
The text was updated successfully, but these errors were encountered:
Change https://go.dev/cl/431736 mentions this issue: gofrontend: fix struct comparison with blank field
gofrontend: fix struct comparison with blank field
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, tested on GCC 12.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run
go run -compiler gccgo issue.go
on code:What did you expect to see?
true
should be printed.What did you see instead?
false
is printed.Run
gccgo -issue.go -fgo-dump-ast
, we can find that *a and *b are not referenced at all:A fix has been proposed at https://go-review.googlesource.com/c/gofrontend/+/431736.
The text was updated successfully, but these errors were encountered: