mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
1c268431f4
commit
faa4fa1a6e
33 changed files with 380 additions and 141 deletions
|
|
@ -160,6 +160,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})
|
||||
}
|
||||
|
||||
// Implemented in assembly, as they take arguments in registers.
|
||||
// Declared here to mark them as ABIInternal.
|
||||
func panicIndex(x int, y int)
|
||||
|
|
@ -178,6 +184,7 @@ func panicSlice3B(x int, y int)
|
|||
func panicSlice3BU(x uint, y int)
|
||||
func panicSlice3C(x int, y int)
|
||||
func panicSlice3CU(x uint, y int)
|
||||
func panicSliceConvert(x int, y int)
|
||||
|
||||
var shiftError = error(errorString("negative shift amount"))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue