aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/error.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2021-03-14 14:24:47 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2021-04-21 00:53:48 +0000
commitfaa4fa1a6e94fce4f6fa22524a2bece5125213b6 (patch)
treeecd5c4b860564b5b1926725f6ffafcebfac3b3d9 /src/runtime/error.go
parent1c268431f49ee2fc843eac52a0854aea3d02a6e0 (diff)
downloadgo-faa4fa1a6e94fce4f6fa22524a2bece5125213b6.tar.gz
go-faa4fa1a6e94fce4f6fa22524a2bece5125213b6.zip
cmd/compile: allow conversion from slice to array ptr
Panic if the slice is too short. Updates #395 Change-Id: I90f4bff2da5d8f3148ba06d2482084f32b25c29a Reviewed-on: https://go-review.googlesource.com/c/go/+/301650 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/runtime/error.go')
-rw-r--r--src/runtime/error.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/error.go b/src/runtime/error.go
index 9e6cdf35dd..91f83ae126 100644
--- a/src/runtime/error.go
+++ b/src/runtime/error.go
@@ -134,6 +134,7 @@ const (
boundsSlice3B // s[?:x:y], 0 <= x <= y failed (but boundsSlice3A didn't happen)
boundsSlice3C // s[x:y:?], 0 <= x <= y failed (but boundsSlice3A/B didn't happen)
+ boundsConvert // (*[x]T)(s), 0 <= x <= len(s) failed
// Note: in the above, len(s) and cap(s) are stored in y
)
@@ -149,6 +150,7 @@ var boundsErrorFmts = [...]string{
boundsSlice3Acap: "slice bounds out of range [::%x] with capacity %y",
boundsSlice3B: "slice bounds out of range [:%x:%y]",
boundsSlice3C: "slice bounds out of range [%x:%y:]",
+ boundsConvert: "cannot convert slice with length %y to pointer to array with length %x",
}
// boundsNegErrorFmts are overriding formats if x is negative. In this case there's no need to report y.