https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61265
--- Comment #2 from Chris Manghane <cmang at google dot com> --- A slightly smaller program can reproduce this as well: package main var a = [1][0]int{B}[0] var B = [0]int{} func main() {} This error occurs because in Gcc_backend::fill_in_array, the type of B, [0]int, is represented using build_array_type(int, build_index_type(len - 1)), where len is 0 in this case, giving it a range of [0:MAX_INT] where it should be [0:0]. The following patch fixes this behavior: Index: gcc/go/go-gcc.cc ====================================================================== --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -887,9 +887,13 @@ Gcc_backend::fill_in_array(Btype* fill, Btype* element_type, // build_index_type takes the maximum index, which is one less than // the length. - tree index_type_tree = build_index_type(fold_build2(MINUS_EXPR, sizetype, - length_tree, - size_one_node)); + tree index_type_tree = NULL_TREE; + if (length_tree == size_zero_node) + index_type_tree = build_index_type(size_zero_node); + else + index_type_tree = build_index_type(fold_build2(MINUS_EXPR, sizetype, + length_tree, + size_one_node)); tree fill_tree = fill->get_tree(); TREE_TYPE(fill_tree) = element_type_tree;