4 ms·
And the line right next to that: > C++11 standard officially bans data races as undefined behavior. Relaxed access of atomics is not UB in C++, that would be
by Manishearth 11y ago
And the line right next to that:
> 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.
- burntsushi 11y agoThere is definitely something special going on with relaxed updates though. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2480.html#unordered http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n248... Also https://news.ycombinator.com/item?id=9796245 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/n2480.html#races http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n248...