diff options
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/runtime/error.go | 2 | ||||
-rw-r--r-- | libgo/go/runtime/panic.go | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/libgo/go/runtime/error.go b/libgo/go/runtime/error.go index 8065534..a8c82bb 100644 --- a/libgo/go/runtime/error.go +++ b/libgo/go/runtime/error.go @@ -175,6 +175,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 ) @@ -190,6 +191,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. diff --git a/libgo/go/runtime/panic.go b/libgo/go/runtime/panic.go index 11396b4..a4b9a83 100644 --- a/libgo/go/runtime/panic.go +++ b/libgo/go/runtime/panic.go @@ -38,6 +38,7 @@ import ( //go:linkname goPanicSlice3BU //go:linkname goPanicSlice3C //go:linkname goPanicSlice3CU +//go:linkname goPanicSliceConvert //go:linkname panicshift //go:linkname panicdivide //go:linkname panicmem @@ -175,6 +176,12 @@ func goPanicSlice3CU(x uint, y int) { panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSlice3C}) } +// failures in the conversion (*[x]T)s, 0 <= x <= y, x == cap(s) +func goPanicSliceConvert(x int, y int) { + panicCheck1(getcallerpc(), "slice length too short to convert to pointer to array") + panic(boundsError{x: int64(x), signed: true, y: y, code: boundsConvert}) +} + var shiftError = error(errorString("negative shift amount")) func panicshift() { |