From 1519271a939ad27da133318dc4bde7e6a41a35b5 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 25 Jun 2021 11:17:43 -0700 Subject: spec: change unsafe.Slice((*T)(nil), 0) to return []T(nil) Updates #46742. Change-Id: I044933a657cd1a5cdb29863e49751df5fe9c258a Reviewed-on: https://go-review.googlesource.com/c/go/+/331069 Run-TryBot: Matthew Dempsky Trust: Matthew Dempsky Trust: Robert Griesemer Reviewed-by: Robert Griesemer --- doc/go_spec.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/go_spec.html b/doc/go_spec.html index b59b37fd55..e0602418e8 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -6789,11 +6789,17 @@ and whose length and capacity are len: (*[len]ArbitraryType)(unsafe.Pointer(ptr))[:] +

+As a special case, if ptr is nil and len is zero, +Slice returns nil. +

+

The len argument must be of integer type or an untyped constant. A constant len argument must be non-negative and representable by a value of type int; if it is an untyped constant it is given type int. -If ptr is nil or len is negative at run time, +At run time, if len is negative, +or if ptr is nil and len is not zero, a run-time panic occurs.

-- cgit v1.2.3-54-g00ecf