Answer by Damon for Can atomic loads be merged in the C++ memory model?
Yes, in your particular example (no otherwise).Your particular example has a single thread of execution, foo has static storage duration and initialization (that is, before main is entered) and it is...
View ArticleAnswer by Filip Roséen - refp for Can atomic loads be merged in the C++...
Yes, because we can not observe the difference!An implementation is allowed to turn your snippet into the following (pseudo-implementation).int __loaded_foo = foo;int x = __loaded_foo;int y =...
View ArticleCan atomic loads be merged in the C++ memory model?
Consider the C++ 11 snippet below. For GCC and clang this compiles to two (sequentially consistent) loads of foo. (Editor's note: compilers do not optimize atomics, see this Q&A for more details,...
View Article
More Pages to Explore .....