https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80226
Bug ID: 80226 Summary: ICE gimple-expr.c:474 on Go function returning multiple empty struct/array values Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: go Assignee: ian at airs dot com Reporter: thanm at google dot com CC: cmang at google dot com Target Milestone: --- Compiling the attached test case with gccgo results in an ICE. Example: $ go build -compiler gccgo repro.go # command-line-arguments In function ‘repro.Test36’: go1: internal compiler error: in create_tmp_var, at gimple-expr.c:474 0xc2ace4 create_tmp_var(tree_node*, char const*) ../../gcc-trunk/gcc/gimple-expr.c:474 0x8f5f37 Gcc_backend::return_statement(Bfunction*, std::vector<Bexpression*, std::allocator<Bexpression*> > const&, Location) ../../gcc-trunk/gcc/go/go-gcc.cc:2135 0x96f3b9 Return_statement::do_get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:2838 0x968480 Statement::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:142 0x91b0f2 Block::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/gogo.cc:6026 0x96c772 Block_statement::do_get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:1850 0x968480 Statement::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:142 0x91b0f2 Block::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/gogo.cc:6026 0x96ff8e If_statement::do_get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:3178 0x968480 Statement::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:142 0x91b0f2 Block::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/gogo.cc:6026 0x96c772 Block_statement::do_get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:1850 0x968480 Statement::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/statements.cc:142 0x91b0f2 Block::get_backend(Translate_context*) ../../gcc-trunk/gcc/go/gofrontend/gogo.cc:6026 0x9198ef Function::build(Gogo*, Named_object*) ../../gcc-trunk/gcc/go/gofrontend/gogo.cc:5629 0x91ebf0 Named_object::get_backend(Gogo*, std::vector<Bexpression*, std::allocator<Bexpression*> >&, std::vector<Btype*, std::allocator<Btype*> >&, std::vector<Bfunction*, std::allocator<Bfunction*> >&) ../../gcc-trunk/gcc/go/gofrontend/gogo.cc:7411 0x90cad1 Gogo::write_globals() ../../gcc-trunk/gcc/go/gofrontend/gogo.cc:1322 0x90679e go_write_globals() ../../gcc-trunk/gcc/go/gofrontend/go.cc:174 0x8fd2e1 go_langhook_parse_file ../../gcc-trunk/gcc/go/go-lang.c:318 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. This is with trunk gccgo: $ gccgo --version gccgo (GCC) 7.0.1 20170322 (experimental) $ Excerpt from the function: func Test36(p0 uint64, p1 StructF36S0, p2 uint8, p3 int32, p4 StructF36S1) (r0 StructF36S2, r1 ArrayF36S0E0, r2 ArrayF36S1E0) { rc0 := StructF36S2{} rc1 := ArrayF36S0E0{} rc2 := ArrayF36S1E0{} if p0 == 0 { return rc0, rc1, rc2 } where r0/r1/r2 are all zero-sized arrays or empty structures. I spent a little while poking around -- from what I can tell there is code already in Gcc_backend::return_statement designed to catch this case (returning empty-sized stuff), however it doesn't appear to be working correctly. Line is if (int_size_in_bytes(TREE_TYPE(result)) == 0) however this call is returning -1 in this case (since TREE_TYPE(result) is the void type). I will work on a fix.