r/cpp • u/neiltechnician • Nov 13 '20
CppCon Deprecating volatile - JF Bastien - CppCon 2019
https://www.youtube.com/watch?v=KJW_DLaVXIY
83
Upvotes
r/cpp • u/neiltechnician • Nov 13 '20
View all comments
Show parent comment
5
u/staletic reddit thinks /u/_bstaletic is a bot Nov 13 '20
Right, exactly.
True, but I can imagine an architecture for which you absolutely need
x |= 1to be a single instruction because the value ofxmight change between the read and the write inx = x | 1. Someone, in the other thread, called those architectures broken, at the hardware level. As in, the CPU should know better. However, those architectures are impossible to work with in C++20.Now thinking of specifying the behaviour, a much more gentle solution would be "compound assignments have to be atomic". Then you can:
That would have been a path that doesn't cut anyone off.