From 83a33d3855e257b383b2a3a10dfd9748ad17cfb4 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 8 Mar 2019 15:01:32 -0800 Subject: cmd/compile: reverse order of slice bounds checks Turns out this makes the fix for 28797 unnecessary, because this order ensures that the RHS of IsSliceInBounds ops are always nonnegative. The real reason for this change is that it also makes dealing with <0 values easier for reporting values in bounds check panics (issue #30116). Makes cmd/go negligibly smaller. Update #28797 Change-Id: I1f25ba6d2b3b3d4a72df3105828aa0a4b629ce85 Reviewed-on: https://go-review.googlesource.com/c/go/+/166377 Run-TryBot: Keith Randall Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- test/prove.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/prove.go') diff --git a/test/prove.go b/test/prove.go index eb0fb2a15e..2db0a841e2 100644 --- a/test/prove.go +++ b/test/prove.go @@ -269,7 +269,7 @@ func f11b(a []int, i int) { func f11c(a []int, i int) { useSlice(a[:i]) - useSlice(a[:i]) // ERROR "Proved Geq64$" "Proved IsSliceInBounds$" + useSlice(a[:i]) // ERROR "Proved IsSliceInBounds$" } func f11d(a []int, i int) { @@ -469,7 +469,7 @@ func f17(b []int) { // using the derived relation between len and cap. // This depends on finding the contradiction, since we // don't query this condition directly. - useSlice(b[:i]) // ERROR "Proved Geq64$" "Proved IsSliceInBounds$" + useSlice(b[:i]) // ERROR "Proved IsSliceInBounds$" } } -- cgit v1.2.1