mirror of
https://github.com/golang/go
synced 2024-11-12 03:10:22 -07:00
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
This commit is contained in:
parent
6ce3e99af0
commit
81eb930f7e
@ -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(&f))
|
||||
|
||||
type ptr unsafe.Pointer
|
||||
bits = *(*uint64)(ptr(&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>
|
||||
|
Loading…
Reference in New Issue
Block a user