go icon indicating copy to clipboard operation
go copied to clipboard

gccgo: cannot compile function that returns a complex64 and an empty struct

Open melonedo opened this issue 3 years ago • 1 comments

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

$ go version
go version go1.18 gccgo (GCC) 13.0.0 20220920 (experimental) linux/amd64

Does this issue reproduce with the latest release?

Yes, commit https://github.com/gcc-mirror/gcc/commit/041812f584a1c82f1255bd96f3503493bd9fb127

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/melonedo/.cache/go-build"
GOENV="/home/melonedo/.config/go/env"
GOEXE=""
GOEXPERIMENT="fieldtrack,regabiwrappers"
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/melonedo/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/melonedo/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/melonedo/build/install-gccgolang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/melonedo/build/install-gccgolang/libexec/gcc/x86_64-pc-linux-gnu/13.0.0"
GOVCS=""
GOVERSION="go1.18 gccgo (GCC) 13.0.0 20220920 (experimental)"
GCCGO="/home/melonedo/build/install-gccgolang/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build3040718934=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

Run go build issue.go on code:

// MWE from signature fuzzer
package main
import "fmt"
import "reflect"

type StructF3S0 struct {
}

//go:noinline
func test() (complex64, StructF3S0) {
  rc0 := complex(float32(-6.1751327e+37),float32(6.408295e+37))
  rc1 := StructF3S0{}
  return rc0, rc1
}

func main() {
  fmt.Println(test())
  rvslice := reflect.ValueOf(test).Call([]reflect.Value{})
  fmt.Println(rvslice[0].Interface().(complex64),  rvslice[1].Interface().(StructF3S0))
}


//go:noinline
func New_0(i float32) *float32 {
  x := new( float32)
  *x = i
  return x
}

What did you expect to see?

(-6.1751327e+37+6.408295e+37i) {}
(-6.1751327e+37+6.408295e+37i) {}

What did you see instead?

gccgo crashes:

# command-line-arguments
go1: internal compiler error: in convert_tree, at go/go-gcc.cc:2713
0x72ef0b Gcc_backend::convert_tree(tree_node*, tree_node*, Location)
        /home/melonedo/gcc/gcc/go/go-gcc.cc:2713
0x97ea90 Gcc_backend::assignment_statement(Bfunction*, Bexpression*, Bexpression*, Location)
        /home/melonedo/gcc/gcc/go/go-gcc.cc:2259
0x96f6a5 Call_expression::do_get_backend(Translate_context*)
        /home/melonedo/gcc/gcc/go/gofrontend/expressions.cc:12933
0x9d9031 Expression_statement::do_get_backend(Translate_context*)
        /home/melonedo/gcc/gcc/go/gofrontend/statements.cc:2149
0x999ad8 Block::get_backend(Translate_context*)
        /home/melonedo/gcc/gcc/go/gofrontend/gogo.cc:7114
0x99a6c7 Function::build(Gogo*, Named_object*)
        /home/melonedo/gcc/gcc/go/gofrontend/gogo.cc:6649
0x9a4359 Gogo::write_globals()
        /home/melonedo/gcc/gcc/go/gofrontend/gogo.cc:1560
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

melonedo avatar Sep 20 '22 10:09 melonedo

cc @ianlancetaylor @thanm

cherrymui avatar Sep 20 '22 18:09 cherrymui

Change https://go.dev/cl/479898 mentions this issue: test: add test that caused a gofrontend crash

gopherbot avatar Mar 28 '23 19:03 gopherbot

Change https://go.dev/cl/479955 mentions this issue: compiler: mark Call_expression multiple results as a result struct

gopherbot avatar Mar 28 '23 20:03 gopherbot