Commit 81eb930f authored by Russ Cox's avatar Russ Cox

spec: clarify that any unsafe.Pointer type is okay in conversion

The spec is not clear about whether this is allowed or not,
but both compilers allow it, because the reflect implementation
takes advantage of it. Document current behavior.

Fixes #4679.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7303064
parent 6ce3e99a
......@@ -5610,9 +5610,18 @@ func Sizeof(variable ArbitraryType) uintptr
</pre>
<p>
Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be converted into
a <code>Pointer</code> and vice versa.
Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be converted to
a <code>Pointer</code> type and vice versa.
</p>
<pre>
var f float64
bits = *(*uint64)(unsafe.Pointer(&amp;f))
type ptr unsafe.Pointer
bits = *(*uint64)(ptr(&amp;f))
</pre>
<p>
The functions <code>Alignof</code> and <code>Sizeof</code> take an expression <code>x</code>
of any type and return the alignment or size, respectively, of a hypothetical variable <code>v</code>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment