-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.18.2 linux/amd64
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
Output
$ 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"
What did you do?
Run go run -compiler gccgo issue.go
on code:
// 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))
}
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:
.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.
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.