]> Cypherpunks repositories - gostls13.git/commitdiff
spec: unsafe.Alignof/Sizeof also accept non-variable arguments
authorRobert Griesemer <gri@golang.org>
Mon, 17 Sep 2012 19:23:41 +0000 (12:23 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 17 Sep 2012 19:23:41 +0000 (12:23 -0700)
Both gc and gccgo permit calls such as unsafe.Sizeof(42). The
spec only permits variable arguments. This is a (backward-compatible)
spec change reflecting the status quo. Seems preferrable over
restricting the compilers.

R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6494140

doc/go_spec.html

index 72582d4a178602938879e175da43896a22dde704..fc61bdd4c07266b547f3d61f00cb646283b67360 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of September 13, 2012",
+       "Subtitle": "Version of September 17, 2012",
        "Path": "/ref/spec"
 }-->
 
@@ -5487,8 +5487,9 @@ Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code
 a <code>Pointer</code> and vice versa.
 </p>
 <p>
-The function <code>Sizeof</code> takes an expression denoting a
-variable of any type and returns the size of the variable in bytes.
+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>
+as if <code>v</code> was declared via <code>var v = x</code>.
 </p>
 <p>
 The function <code>Offsetof</code> takes a selector (ยง<a href="#Selectors">Selectors</a>) denoting a struct