From 173dce8d2029cc3797537431b93d9ab04e135289 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 27 Feb 2020 11:08:30 -0800 Subject: [PATCH] cmd/compile: check rune type bounds as int32, not uint32 Also, avoid string(i) where i has type int. Updates #32479 Change-Id: If3c6edc8523860082726e034ef9e887b5f7fabd1 Reviewed-on: https://go-review.googlesource.com/c/go/+/221382 Run-TryBot: Ian Lance Taylor Reviewed-by: Matthew Dempsky TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/const.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd/compile/internal/gc/const.go b/src/cmd/compile/internal/gc/const.go index 0c03aad12b..5e5b32bc4a 100644 --- a/src/cmd/compile/internal/gc/const.go +++ b/src/cmd/compile/internal/gc/const.go @@ -540,11 +540,11 @@ func overflow(v Val, t *types.Type) bool { func tostr(v Val) Val { switch u := v.U.(type) { case *Mpint: - var i int64 = 0xFFFD - if u.Cmp(minintval[TUINT32]) >= 0 && u.Cmp(maxintval[TUINT32]) <= 0 { - i = u.Int64() + var r rune = 0xFFFD + if u.Cmp(minintval[TINT32]) >= 0 && u.Cmp(maxintval[TINT32]) <= 0 { + r = rune(u.Int64()) } - v.U = string(i) + v.U = string(r) } return v -- 2.50.0