]> Cypherpunks repositories - gostls13.git/commitdiff
spec: pointer comparison for pointers to 0-sized variables
authorRobert Griesemer <gri@golang.org>
Tue, 10 Jan 2012 00:54:24 +0000 (16:54 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 10 Jan 2012 00:54:24 +0000 (16:54 -0800)
- define "0-sized"
- add clarifying sentence to pointer comparison
- removed notion "location" which was used only in pointer comparisons
  and which was never defined

Fixes #2620.

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

doc/go_spec.html

index 4e00aabf45e0dcc534f6313b21bc9027240ebcf7..0f095da814c0b623a0b68437b756afedcc54f8a2 100644 (file)
@@ -1,5 +1,5 @@
 <!-- title The Go Programming Language Specification -->
-<!-- subtitle Version of December 15, 2011 -->
+<!-- subtitle Version of January 9, 2012 -->
 
 <!--
 TODO
@@ -13,7 +13,6 @@ TODO
 [ ] should probably write something about evaluation order of statements even
        though obvious
 [ ] review language on implicit dereferencing
-[ ] clarify what it means for two functions to be "the same" when comparing them
 -->
 
 
@@ -2957,7 +2956,8 @@ These terms and the result of the comparisons are defined as follows:
        
        <li>
        Pointer values are comparable.
-       Two pointer values are equal if they point to the same location or if both have value <code>nil</code>.
+       Two pointer values are equal if they point to the same variable or if both have value <code>nil</code>.
+       Pointers to distinct <a href="#Size_and_alignment_guarantees">zero-size</a> variables may or may not be equal.
        </li>
        
        <li>
@@ -5348,6 +5348,11 @@ The following minimal alignment properties are guaranteed:
 </li>
 </ol>
 
+<p>
+A struct or array type has size zero if it contains no fields (or elements, respectively) that have a size greater than zero. Two distinct zero-size variables may have the same address in memory.
+</p>
+
+
 <span class="alert">
 <h2 id="Implementation_differences">Implementation differences - TODO</h2>
 <ul>