From: Russ Cox Date: Sat, 9 Feb 2013 22:36:31 +0000 (-0500) Subject: spec: clarify that any unsafe.Pointer type is okay in conversion X-Git-Tag: go1.1rc2~1089 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=81eb930f7e021e334ec2b54dc4ba6b1ab825887f;p=gostls13.git 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 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 30c9a9766c..f18585a2e9 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -5610,9 +5610,18 @@ func Sizeof(variable ArbitraryType) uintptr

-Any pointer or value of underlying type uintptr can be converted into -a Pointer and vice versa. +Any pointer or value of underlying type uintptr can be converted to +a Pointer type and vice versa.

+ +
+var f float64
+bits = *(*uint64)(unsafe.Pointer(&f))
+
+type ptr unsafe.Pointer
+bits = *(*uint64)(ptr(&f))
+
+

The functions Alignof and Sizeof take an expression x of any type and return the alignment or size, respectively, of a hypothetical variable v