aboutsummaryrefslogtreecommitdiff
path: root/test/checkbce.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-11-27 11:43:08 -0800
committerKeith Randall <khr@golang.org>2017-02-02 17:45:58 +0000
commit73f92f9b0405e98427bbb445f24cffb5d3c4d01b (patch)
tree05df0d7b52dc6316d6b939d8d817b2f91e8d4595 /test/checkbce.go
parent6317f92f6e51f679712deec6094c6b5fc2948a5b (diff)
downloadgo-73f92f9b0405e98427bbb445f24cffb5d3c4d01b.tar.gz
go-73f92f9b0405e98427bbb445f24cffb5d3c4d01b.zip
cmd/compile: use len(s)<=cap(s) to remove more bounds checks
When we discover a relation x <= len(s), also discover the relation x <= cap(s). That way, in situations like: a := s[x:] // tests 0 <= x <= len(s) b := s[:x] // tests 0 <= x <= cap(s) the second check can be eliminated. Fixes #16813 Change-Id: Ifc037920b6955e43bac1a1eaf6bac63a89cfbd44 Reviewed-on: https://go-review.googlesource.com/33633 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/checkbce.go')
-rw-r--r--test/checkbce.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/checkbce.go b/test/checkbce.go
index 59bd41b360..4f9574d420 100644
--- a/test/checkbce.go
+++ b/test/checkbce.go
@@ -50,7 +50,7 @@ func f5(a []int) {
if len(a) > 5 {
useInt(a[5])
useSlice(a[6:])
- useSlice(a[:6]) // ERROR "Found IsSliceInBounds$"
+ useSlice(a[:6])
}
}