Skip to content

Commit bd8a3ee

Browse files
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
1 parent fdd5981 commit bd8a3ee

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

gcc/go/gofrontend/MERGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
3f597287b6b858794dabdfe1bf83b386aad18102
1+
98e92493db2ab7857a5934a950a830fc1f95a4e5
22

33
The first line of this file holds the git revision number of the last
44
merge done from the gofrontend repository.

gcc/go/gofrontend/expressions.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -18790,7 +18790,7 @@ Composite_literal_expression::lower_array(Type* type)
1879018790

1879118791
Named_type* ntype = Type::lookup_integer_type("int");
1879218792
Integer_type* inttype = ntype->integer_type();
18793-
if (sizeof(index) <= static_cast<size_t>(inttype->bits() * 8)
18793+
if (sizeof(index) >= static_cast<size_t>(inttype->bits() / 8)
1879418794
&& index >> (inttype->bits() - 1) != 0)
1879518795
{
1879618796
go_error_at(index_expr->location(), "index value overflow");

0 commit comments

Comments
 (0)