29 ms·
While he's technically right, you have no guarantee that the value as a whole is written unless you use the proper fences or synchronize it in some way.
by vvanders 7y ago
While he's technically right, you have no guarantee that the value as a whole is written unless you use the proper fences or synchronize it in some way.
- iainmerrick 7y ago“While he's technically right, you have no guarantee” Well, is he technically right or not? It sounds like you think he is not right.
- rocqua 7y agoHe's right on assembly level of assignment, but the compiler is free to emit assembly that will tear. Some compilers might do that for optimization purposes.
- Sharlin 7y agoThe (C or C++) compiler is free to do anything because reading and writing a non-`atomic` variable from two different threads without synchronization is undefined behavior.
- vvanders 7y agoHe's right that the value will be moved atomically, however the compiler is free to reorder the store/load of fences are omitted.