diff mbox

Go patch committed: Don't crash on array assignment

Message ID mcrboo7swgc.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor March 8, 2012, 1:38 a.m. UTC
The Go frontend crashed doing an array assignment of two values of type
[2][]int.  This patch fixes it.  Normal array assignments worked because
gcc uses the same structure for all arrays with the same length and
element type.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 3a8aa04c3a9a go/expressions.cc
--- a/go/expressions.cc	Wed Mar 07 13:51:48 2012 -0800
+++ b/go/expressions.cc	Wed Mar 07 17:36:41 2012 -0800
@@ -284,8 +284,10 @@ 
 	   || SCALAR_FLOAT_TYPE_P(lhs_type_tree)
 	   || COMPLEX_FLOAT_TYPE_P(lhs_type_tree))
     return fold_convert_loc(location.gcc_location(), lhs_type_tree, rhs_tree);
-  else if (TREE_CODE(lhs_type_tree) == RECORD_TYPE
-	   && TREE_CODE(TREE_TYPE(rhs_tree)) == RECORD_TYPE)
+  else if ((TREE_CODE(lhs_type_tree) == RECORD_TYPE
+	    && TREE_CODE(TREE_TYPE(rhs_tree)) == RECORD_TYPE)
+	   || (TREE_CODE(lhs_type_tree) == ARRAY_TYPE
+	       && TREE_CODE(TREE_TYPE(rhs_tree)) == ARRAY_TYPE))
     {
       // This conversion must be permitted by Go, or we wouldn't have
       // gotten here.