aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-08-25 20:31:51 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-08-25 20:31:51 +0000
commit60c47c007366840f15fe17913d0592c2819b7c99 (patch)
tree7fbced9827c20185a4d4e974394081364996d9a4 /gcc/go
parentc316b5e4f1f7987e37641667fb47eb37f32f0e2b (diff)
downloadgcc-60c47c007366840f15fe17913d0592c2819b7c99.zip
gcc-60c47c007366840f15fe17913d0592c2819b7c99.tar.gz
gcc-60c47c007366840f15fe17913d0592c2819b7c99.tar.bz2
compiler: Allow string slices with start index == length.
Avoid an off-by-one error when checking the start index of a string slice by allowing the start index to be the string length instead of the string length - 1. Fixes golang/go#11522. Reviewed-on: https://go-review.googlesource.com/13030 From-SVN: r227191
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc5
2 files changed, 5 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 1bde669..86d163b 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-d6d59d5927c4ea0c02468ebc6a2df431fb64595a
+14ca4b6130b9a7132d132f418e9ea283b3a52c08
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index c0e5fc5..f1873cd 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -10341,7 +10341,10 @@ String_index_expression::do_check_types(Gogo*)
{
ival_valid = true;
if (mpz_sgn(ival) < 0
- || (sval_valid && mpz_cmp_ui(ival, sval.length()) >= 0))
+ || (sval_valid
+ && (this->end_ == NULL
+ ? mpz_cmp_ui(ival, sval.length()) >= 0
+ : mpz_cmp_ui(ival, sval.length()) > 0)))
{
error_at(this->start_->location(), "string index out of bounds");
this->set_is_error();