]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: check rune type bounds as int32, not uint32
authorIan Lance Taylor <iant@golang.org>
Thu, 27 Feb 2020 19:08:30 +0000 (11:08 -0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 27 Feb 2020 19:30:09 +0000 (19:30 +0000)
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 <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/const.go

index 0c03aad12b0cf00cc6c3e1be55b1b4f24d5ad807..5e5b32bc4a2ff611dbfb16e6e4f350e4b71dcf20 100644 (file)
@@ -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