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: cannot compile function that returns a complex64 and an empty struct #55242

Closed
melonedo opened this issue Sep 20, 2022 · 3 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@melonedo
Copy link

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 gcc-mirror/gcc@041812f

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.
@gopherbot gopherbot added this to the Gccgo milestone Sep 20, 2022
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 20, 2022
@cherrymui
Copy link
Member

cc @ianlancetaylor @thanm

@gopherbot
Copy link

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

@gopherbot
Copy link

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

gopherbot pushed a commit that referenced this issue Mar 28, 2023
For #55242

Change-Id: I092b1881623ea997b178d038c0afd10cd5bca937
Reviewed-on: https://go-review.googlesource.com/c/go/+/479898
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
nstester pushed a commit to nstester/gcc that referenced this issue Mar 29, 2023
In https://go.dev/cl/343873 we stopped padding zero-sized trailing
fields in functions that return multiple results where the last result
is zero-sized. This CL makes the corresponding change on the caller side.

The test case is https://go.dev/cl/479898.

Fixes golang/go#55242

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/479955
@golang golang locked and limited conversation to collaborators Mar 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants