mirror of
https://github.com/golang/go
synced 2024-10-06 08:00:07 +00:00
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 <gri@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
68da368a4e
commit
61ff501968
|
@ -642,7 +642,7 @@ an identifier denoting a constant,
|
|||
a <a href="#Constant_expressions">constant expression</a>,
|
||||
a <a href="#Conversions">conversion</a> with a result that is a constant, or
|
||||
the result value of some built-in functions such as
|
||||
<code>unsafe.Sizeof</code> applied to any value,
|
||||
<code>unsafe.Sizeof</code> applied to <a href="#Package_unsafe">certain values</a>,
|
||||
<code>cap</code> or <code>len</code> applied to
|
||||
<a href="#Length_and_capacity">some expressions</a>,
|
||||
<code>real</code> and <code>imag</code> applied to a complex constant
|
||||
|
@ -7446,8 +7446,14 @@ uintptr(unsafe.Pointer(&x)) % unsafe.Alignof(x) == 0
|
|||
</pre>
|
||||
|
||||
<p>
|
||||
Calls to <code>Alignof</code>, <code>Offsetof</code>, and
|
||||
<code>Sizeof</code> are compile-time constant expressions of type <code>uintptr</code>.
|
||||
A (variable of) type <code>T</code> has <i>variable size</i> if <code>T</code>
|
||||
is a type parameter, or if it is an array or struct type containing elements
|
||||
or fields of variable size. Otherwise the size is <i>constant</i>.
|
||||
Calls to <code>Alignof</code>, <code>Offsetof</code>, and <code>Sizeof</code>
|
||||
are compile-time <a href="#Constant_expressions">constant expressions</a> of
|
||||
type <code>uintptr</code> if their arguments (or the struct <code>s</code> in
|
||||
the selector expression <code>s.f</code> for <code>Offsetof</code>) are types
|
||||
of constant size.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
Loading…
Reference in a new issue