Go patch committed: Don't crash indexing into erroneous array

Submitted by Ian Taylor on Dec. 21, 2010, 10:58 p.m.

Details

Message ID mcrei9alolz.fsf@google.com
State New
Headers show

Commit Message

Ian Taylor Dec. 21, 2010, 10:58 p.m.
This patch fixes the Go compiler to not crash when indexing into an
erroneous array.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch hide | download patch | download mbox

diff -r 4942fa9d5d0e go/expressions.cc
--- a/go/expressions.cc	Tue Dec 21 14:54:39 2010 -0800
+++ b/go/expressions.cc	Tue Dec 21 14:56:49 2010 -0800
@@ -9154,7 +9154,11 @@ 
   source_location loc = this->location();
 
   Array_type* array_type = this->array_->type()->array_type();
-  gcc_assert(array_type != NULL);
+  if (array_type == NULL)
+    {
+      gcc_assert(this->array_->type()->is_error_type());
+      return error_mark_node;
+    }
 
   tree type_tree = array_type->get_tree(gogo);
   if (type_tree == error_mark_node)