Compiler optimizations like loop fusion move statements in the program, which can influence the order of read and write operations of potentially shared variables.
The memory model stipulates that changes to the values of shared variables only need to be made visible to other threads when such a synchronization barrier is reached.
Moreover, the entire notion of a race condition is defined over the order of operations with respect to these memory barriers.
[2] After it was established that threads could not be implemented safely as a library without placing certain restrictions on the implementation and, in particular, that the C and C++ standards (C99 and C++03) lacked necessary restrictions,[3][4] the C++ threading subcommittee set to work on suitable memory model; in 2005, they submitted C working document n1131[5] to get the C Committee on board with their efforts.
The final revision of the proposed memory model, C++ n2429,[6] was accepted into the C++ draft standard at the October 2007 meeting in Kona.