compiler: avoid silent truncation for string(1 << 32)
authorIan Lance Taylor <iant@golang.org>
Tue, 24 Nov 2020 01:48:28 +0000 (17:48 -0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 25 Nov 2020 16:02:39 +0000 (08:02 -0800)
commit4aff491ffcb1312c7745758301df6d22c0c70200
tree99abab43b95764f90644c04d9657f018914ae529
parent049ce9d233e2d865dc81a5042b1c28ee21d1c9d8
compiler: avoid silent truncation for string(1 << 32)

In the conversion of a constant integer to a string type, the value of
the constant integer was being silently truncated from unsigned long
to unsigned int, producing the wrong string value.  Add an explicit
overflow check to avoid this problem.

For golang/go#42790

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/272611
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc