projects
/
platform
/
upstream
/
gcc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3a24b26
)
compiler: Check for nil when slicing pointer to array.
author
Ian Lance Taylor
<ian@gcc.gnu.org>
Thu, 12 Dec 2013 21:03:10 +0000
(21:03 +0000)
committer
Ian Lance Taylor
<ian@gcc.gnu.org>
Thu, 12 Dec 2013 21:03:10 +0000
(21:03 +0000)
From-SVN: r205942
gcc/go/gofrontend/expressions.cc
patch
|
blob
|
history
diff --git
a/gcc/go/gofrontend/expressions.cc
b/gcc/go/gofrontend/expressions.cc
index
a5a056b
..
35bcdbb
100644
(file)
--- a/
gcc/go/gofrontend/expressions.cc
+++ b/
gcc/go/gofrontend/expressions.cc
@@
-10259,6
+10259,14
@@
Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
{
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())