Message ID | mcreh5hixyn.fsf@iant-glaptop.roam.corp.google.com |
---|---|
State | New |
Headers | show |
diff -r befe27e79459 go/expressions.cc --- a/go/expressions.cc Thu Dec 12 12:41:44 2013 -0800 +++ b/go/expressions.cc Thu Dec 12 13:00:22 2013 -0800 @@ -10259,6 +10259,14 @@ { Expression* deref = Expression::make_unary(OPERATOR_MULT, left, location); + + // For an ordinary index into the array, the pointer will be + // dereferenced. For a slice it will not--the resulting slice + // will simply reuse the pointer, which is incorrect if that + // pointer is nil. + if (end != NULL || cap != NULL) + deref->issue_nil_check(); + return Expression::make_array_index(deref, start, end, cap, location); } else if (type->is_string_type())