From: Ian Lance Taylor Date: Thu, 27 Feb 2020 19:08:30 +0000 (-0800) Subject: cmd/compile: check rune type bounds as int32, not uint32 X-Git-Tag: go1.15beta1~1027 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=173dce8d2029cc3797537431b93d9ab04e135289;p=gostls13.git 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 --- 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