]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: use correct size and comparison in index value overflow check
authorIan Lance Taylor <iant@golang.org>
Wed, 27 Mar 2024 20:37:45 +0000 (13:37 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 27 Mar 2024 23:09:31 +0000 (16:09 -0700)
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

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc

index de6e21fb3b53e6ad690fc27f7114517d4f1ac2cb..50d430d503431278b0fbd43edf0d7fff8d78b83e 100644 (file)
@@ -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.
index 8429e553eac93bfdb6dff349f1fb926813f40bf1..238d5a56ca2ae70ba1dc49de9016a2b8574c0f6b 100644 (file)
@@ -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");