This patch by Chris Manghane fixes the Go frontend to avoid crashes when initializing zero-sized temporary values. This is GCC PR 61204. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian 2015-01-07 Chris Manghane <cm...@google.com> PR go/61204 * go-gcc.cc (Gcc_backend::temporary_variable): Don't initialize zero-sized variable.
Index: go-gcc.cc =================================================================== --- go-gcc.cc (revision 219262) +++ go-gcc.cc (working copy) @@ -2536,7 +2536,7 @@ Gcc_backend::temporary_variable(Bfunctio BIND_EXPR_VARS(bind_tree) = BLOCK_VARS(block_tree); } - if (init_tree != NULL_TREE) + if (this->type_size(btype) != 0 && init_tree != NULL_TREE) DECL_INITIAL(var) = fold_convert_loc(location.gcc_location(), type_tree, init_tree); @@ -2546,6 +2546,13 @@ Gcc_backend::temporary_variable(Bfunctio *pstatement = this->make_statement(build1_loc(location.gcc_location(), DECL_EXPR, void_type_node, var)); + + // Don't initialize VAR with BINIT, but still evaluate BINIT for + // its side effects. + if (this->type_size(btype) == 0 && init_tree != NULL_TREE) + *pstatement = this->compound_statement(this->expression_statement(binit), + *pstatement); + return new Bvariable(var); }