Hacker News new | ask | show | jobs
by alvarelle 2033 days ago
> ... std::atomic<bool>. This tells the compiler not to elide reads and writes of this variable, ...

If I'm not mistaken, this is not true. The compiler is still allowed to elide reads and writes on atomic variables. (For example merge two consecutive writes, or remove unused reads)

2 comments

Correct. See "N4455 No Sane Compiler Would Optimize Atomics" [1]. The first sentence of that paper is (spoiler allert) a laconic "false".

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n445...

Updated. Thanks for the correction.