Hacker News new | past | comments | ask | show | jobs | submit login

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.



“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.


He'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.


The (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.


He's right that the value will be moved atomically, however the compiler is free to reorder the store/load of fences are omitted.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: