Skip to content

Commit 977e23a

Browse files
committed
doc/go_mem: explain arrays, structs, and complex numbers
Arrays, structs, and complex numbers are collections of values that are handled separately by the memory model. An earlier version may have said this, but the current version does not. Say it. Change-Id: If3928bed6659e58e688f88aa0dde05423cbb3820 Reviewed-on: https://go-review.googlesource.com/c/go/+/514476 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 26fc4aa commit 977e23a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

doc/go_mem.html

+13-2
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,26 @@ <h2 id="restrictions">Implementation Restrictions for Programs Containing Data R
221221
</p>
222222

223223
<p>
224-
First, any implementation can, upon detecting a data race,
224+
Any implementation can, upon detecting a data race,
225225
report the race and halt execution of the program.
226226
Implementations using ThreadSanitizer
227227
(accessed with “<code>go</code> <code>build</code> <code>-race</code>”)
228228
do exactly this.
229229
</p>
230230

231231
<p>
232-
Otherwise, a read <i>r</i> of a memory location <i>x</i>
232+
A read of an array, struct, or complex number
233+
may by implemented as a read of each individual sub-value
234+
(array element, struct field, or real/imaginary component),
235+
in any order.
236+
Similarly, a write of an array, struct, or complex number
237+
may be implemented as a write of each individual sub-value,
238+
in any order.
239+
</p>
240+
241+
<p>
242+
A read <i>r</i> of a memory location <i>x</i>
243+
holding a value
233244
that is not larger than a machine word must observe
234245
some write <i>w</i> such that <i>r</i> does not happen before <i>w</i>
235246
and there is no write <i>w'</i> such that <i>w</i> happens before <i>w'</i>

0 commit comments

Comments
 (0)