C++11 memory model and accessing different members of the same struct in different threads
问题 Assume you've got the following definitions: struct X { char a, b; }; X x; And now assume you have two threads, one of which reads and writes x.a but never accesses x.b while the other one reads and writes x.b but never accesses x.a . Neither thread uses any locks or other synchronization primitives. Is this guaranteed to work in C++11? Or does it count as accessing the same object, and therefore need a lock? 回答1: It's safe. Quoting C++11: [intro.memory]p3: A memory location is either an