]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove index out of bounds check in walkIndex
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 6 Aug 2022 18:55:52 +0000 (01:55 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 8 Aug 2022 16:07:17 +0000 (16:07 +0000)
Since when any user errors about out-of-bounds constants should have
been already reported by types2.

Change-Id: I81b6bfec53201bbf546c48157fc8154cdb3c6e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/421876
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/walk/expr.go

index 83fcea38d5b9afec8a3f0c7827a56426139350a0..dfa82e7ec03cc5610555610f194b368490196faa 100644 (file)
@@ -727,23 +727,11 @@ func walkIndex(n *ir.IndexExpr, init *ir.Nodes) ir.Node {
                if base.Flag.LowerM != 0 && n.Bounded() && !ir.IsConst(n.Index, constant.Int) {
                        base.Warn("index bounds check elided")
                }
-               if ir.IsSmallIntConst(n.Index) && !n.Bounded() {
-                       base.Errorf("index out of bounds")
-               }
        } else if ir.IsConst(n.X, constant.String) {
                n.SetBounded(bounded(r, int64(len(ir.StringVal(n.X)))))
                if base.Flag.LowerM != 0 && n.Bounded() && !ir.IsConst(n.Index, constant.Int) {
                        base.Warn("index bounds check elided")
                }
-               if ir.IsSmallIntConst(n.Index) && !n.Bounded() {
-                       base.Errorf("index out of bounds")
-               }
-       }
-
-       if ir.IsConst(n.Index, constant.Int) {
-               if v := n.Index.Val(); constant.Sign(v) < 0 || ir.ConstOverflow(v, types.Types[types.TINT]) {
-                       base.Errorf("index out of bounds")
-               }
        }
        return n
 }