May 2019

C++ 11 Atomics and Concurrency Memory Model – Part 1

What is the problem. Let us assume we have this source code that we want to compile. What if the compiler during the compilation reorders the instructions into this: Does it change the behavior of the program? As you can see both the codes above will result in z = 7. There is no change in the behavior of the program. In fact, it is perfectly valid for the compiler