http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n233...
There is a lot more explanation here that should cast some light on the situation: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n248...
This necessitates some level of synchronization.
> C++11 standard officially bans data races as undefined behavior.
Relaxed access of atomics is not UB in C++, that would be ridiculous. Clearly one of these two sentences is wrong or imprecise; I would bet it's the first one.
Also https://news.ycombinator.com/item?id=9796245
I think your initial suspicion is right. The next section: "There are several possible definitions of a data race. Probably the most intuitive definition is that it occurs when two ordinary accesses to a scalar, at least one of which is a write, are performed simultaneously by different threads. Our definition is actually quite close to this, but varies in two ways:" ... "Instead of restricting simultaneous execution, we ask that conflicting accesses by different threads be ordered by happens-before. This is equivalent in simpler cases, but the definition based on simultaneous execution would be inappropriate for weakly ordered atomics." continues at: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n248...
A race condition or race hazard is the behavior of an
electronic, software or other system where the output is
dependent on the sequence or timing of other
uncontrollable events.
Example: https://gist.github.com/anonymous/eb72f1091bd1592df552Output:
$ for i in {0..10000}; do ./race; done | sort | uniq
0
1See http://blog.regehr.org/archives/490 for more. But the TL;DR is:
A data race happens when there are two memory accesses in a program where both:
* target the same location
* are performed concurrently by two threads
* are not reads
* are not synchronization operations
I would argue you have a race condition but not a data race.http://blog.regehr.org/archives/490 has a fairly good discussion of the generally accepted definition of data race.