<!--{
"Title": "The Go Memory Model",
- "Subtitle": "Version of May 31, 2014",
+ "Subtitle": "Version of June 6, 2022",
"Path": "/ref/mem"
}-->
“<a href="https://www.hpl.hp.com/techreports/2008/HPL-2008-56.pdf">Foundations of the C++ Concurrency Memory Model</a>”,
published in PLDI 2008.
The definition of data-race-free programs and the guarantee of sequential consistency
-for race-free progams are equivalent to the ones in that work.
+for race-free programs are equivalent to the ones in that work.
</p>
<p>
For an ordinary (non-synchronizing) data read <i>r</i> on a memory location <i>x</i>,
<i>W</i>(<i>r</i>) must be a write <i>w</i> that is <i>visible</i> to <i>r</i>,
where visible means that both of the following hold:
+</p>
<ol>
<li><i>w</i> happens before <i>r</i>.
<p>
Certain Go language operations such as goroutine creation and memory allocation
-act as synchronization opeartions.
+act as synchronization operations.
The effect of these operations on the synchronized-before partial order
is documented in the “Synchronization” section below.
Individual packages are responsible for providing similar documentation
</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>”)
</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>