From 61ff5019687c125910c48c22d672a9b6985ee61e Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sun, 28 Nov 2021 15:25:09 -0800 Subject: [PATCH] spec: adjust section on package unsafe for type parameters Change-Id: I562d4648756e710020ee491f3801896563a89baa Reviewed-on: https://go-review.googlesource.com/c/go/+/367395 Trust: Robert Griesemer Trust: Dan Scales Reviewed-by: Ian Lance Taylor --- doc/go_spec.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 8643d94476..2832b0739d 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -642,7 +642,7 @@ an identifier denoting a constant, a constant expression, a conversion with a result that is a constant, or the result value of some built-in functions such as -unsafe.Sizeof applied to any value, +unsafe.Sizeof applied to certain values, cap or len applied to some expressions, real and imag applied to a complex constant @@ -7446,8 +7446,14 @@ uintptr(unsafe.Pointer(&x)) % unsafe.Alignof(x) == 0

-Calls to Alignof, Offsetof, and -Sizeof are compile-time constant expressions of type uintptr. +A (variable of) type T has variable size if T +is a type parameter, or if it is an array or struct type containing elements +or fields of variable size. Otherwise the size is constant. +Calls to Alignof, Offsetof, and Sizeof +are compile-time constant expressions of +type uintptr if their arguments (or the struct s in +the selector expression s.f for Offsetof) are types +of constant size.

-- 2.50.0