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:
Josh Bleecher Snyder 2021-03-14 14:24:47 -07:00
parent 1c268431f4
commit faa4fa1a6e
33 changed files with 380 additions and 141 deletions

View file

@ -479,6 +479,10 @@ var genericOps = []opData{
{name: "SlicePtr", argLength: 1, typ: "BytePtr"}, // ptr(arg0)
{name: "SliceLen", argLength: 1}, // len(arg0)
{name: "SliceCap", argLength: 1}, // cap(arg0)
// SlicePtrUnchecked, like SlicePtr, extracts the pointer from a slice.
// SlicePtr values are assumed non-nil, because they are guarded by bounds checks.
// SlicePtrUnchecked values can be nil.
{name: "SlicePtrUnchecked", argLength: 1},
// Complex (part/whole)
{name: "ComplexMake", argLength: 2}, // arg0=real, arg1=imag