Hello...
I have just read this about the C++11 Memory Model:
Some programming languages offer SC in multiprocessor environment. In
C++11, you can declare all shared variables as C++11 atomic types with
default memory ordering constraints. In Java, you can mark all shared
variables as volatile [1] [2].
Because the C++11 atomic types guarantee sequential consistency, the
outcome r1 = r2 = 0 is impossible. To achieve this, the compiler outputs
additional instructions behind the scenes – typically memory fences
and/or RMW operations. Those additional instructions may make the
implementation less efficient compared to one where the programmer has
dealt with memory ordering directly.
Read here:
https://people.cs.pitt.edu/~xianeizhang/notes/cpp11_mem.html
So, there is still a problem with C++, because so it is still error
prone if you forget C++11 atomic types to ensure sequential consistency
and it is less efficient with atomic types.
So i still prefer Delphi and FreePascal that don't reorder loads and stores.
Thank you,
Amine Moulay Ramdane.