Skip to content

Commit

Permalink
doc/go_mem: explain arrays, structs, and complex numbers
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rsc committed Jul 31, 2023
1 parent 26fc4aa commit 977e23a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions doc/go_mem.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,26 @@ <h2 id="restrictions">Implementation Restrictions for Programs Containing Data R
</p>

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

<p>
Otherwise, a read <i>r</i> of a memory location <i>x</i>
A read of an array, struct, or complex number
may by implemented as a read of each individual sub-value
(array element, struct field, or real/imaginary component),
in any order.
Similarly, a write of an array, struct, or complex number
may be implemented as a write of each individual sub-value,
in any order.
</p>

<p>
A read <i>r</i> of a memory location <i>x</i>
holding a value
that is not larger than a machine word must observe
some write <i>w</i> such that <i>r</i> does not happen before <i>w</i>
and there is no write <i>w'</i> such that <i>w</i> happens before <i>w'</i>
Expand Down

0 comments on commit 977e23a

Please sign in to comment.