Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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




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

Search: