From 81eb930f7e021e334ec2b54dc4ba6b1ab825887f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 9 Feb 2013 17:36:31 -0500 Subject: [PATCH] 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 --- doc/go_spec.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 -- 2.50.0