aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/checkptr_test.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-25 11:07:28 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-28 23:31:13 +0000
commit4bb0847b088eb3eb6122a18a87e1ca7756281dcc (patch)
tree9baa7b329f0ec4cfdc2f80a833e14070794fe76c /src/runtime/checkptr_test.go
parent1519271a939ad27da133318dc4bde7e6a41a35b5 (diff)
downloadgo-4bb0847b088eb3eb6122a18a87e1ca7756281dcc.tar.gz
go-4bb0847b088eb3eb6122a18a87e1ca7756281dcc.zip
cmd/compile,runtime: change unsafe.Slice((*T)(nil), 0) to return []T(nil)
This CL removes the unconditional OCHECKNIL check added in walkUnsafeSlice by instead passing it as a pointer to runtime.unsafeslice, and hiding the check behind a `len == 0` check. While here, this CL also implements checkptr functionality for unsafe.Slice and disallows use of unsafe.Slice with //go:notinheap types. Updates #46742. Change-Id: I743a445ac124304a4d7322a7fe089c4a21b9a655 Reviewed-on: https://go-review.googlesource.com/c/go/+/331070 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/checkptr_test.go')
-rw-r--r--src/runtime/checkptr_test.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/checkptr_test.go b/src/runtime/checkptr_test.go
index 194cc1243a..2a5c364e97 100644
--- a/src/runtime/checkptr_test.go
+++ b/src/runtime/checkptr_test.go
@@ -30,6 +30,8 @@ func TestCheckPtr(t *testing.T) {
{"CheckPtrArithmetic2", "fatal error: checkptr: pointer arithmetic result points to invalid allocation\n"},
{"CheckPtrSize", "fatal error: checkptr: converted pointer straddles multiple allocations\n"},
{"CheckPtrSmall", "fatal error: checkptr: pointer arithmetic computed bad pointer value\n"},
+ {"CheckPtrSliceOK", ""},
+ {"CheckPtrSliceFail", "fatal error: checkptr: unsafe.Slice result straddles multiple allocations\n"},
}
for _, tc := range testCases {