diff options
author | Ian Lance Taylor <iant@golang.org> | 2024-03-27 13:37:45 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2024-03-27 16:09:31 -0700 |
commit | bd8a3eecc4edffad6e5091ae42c1cb1c1730b2ab (patch) | |
tree | a73097744fea5f55c3459a76dcc1bf0a27de6a28 /gcc | |
parent | fdd59818e2abf6043f4d45aeb157e95956c71088 (diff) | |
download | gcc-bd8a3eecc4edffad6e5091ae42c1cb1c1730b2ab.zip gcc-bd8a3eecc4edffad6e5091ae42c1cb1c1730b2ab.tar.gz gcc-bd8a3eecc4edffad6e5091ae42c1cb1c1730b2ab.tar.bz2 |
compiler: use correct size and comparison in index value overflow check
This has apparently been wrong since I introduced the code ten years ago.
Fixes PR go/114500
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/574835
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index de6e21f..50d430d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -3f597287b6b858794dabdfe1bf83b386aad18102 +98e92493db2ab7857a5934a950a830fc1f95a4e5 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 8429e55..238d5a5 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -18790,7 +18790,7 @@ Composite_literal_expression::lower_array(Type* type) Named_type* ntype = Type::lookup_integer_type("int"); Integer_type* inttype = ntype->integer_type(); - if (sizeof(index) <= static_cast<size_t>(inttype->bits() * 8) + if (sizeof(index) >= static_cast<size_t>(inttype->bits() / 8) && index >> (inttype->bits() - 1) != 0) { go_error_at(index_expr->location(), "index value overflow"); |