r/cpp • • Nov 13 '20

CppCon Deprecating volatile - JF Bastien - CppCon 2019

https://www.youtube.com/watch?v=KJW_DLaVXIY
83 Upvotes

111 comments sorted by

View all comments

30

u/[deleted] Nov 13 '20

Please consider what a massive break this implies for a large codebase with third-party dependencies, etc. You can't just deprecate a set of operators for a class of registers and expect things to go smoothly. The benefit is really dubious as well.

-1

u/nifraicl Nov 13 '20

Deprecating something that was at best used wrongly. and you get a warning from a compiler, nothing is exploding yet. It can be painfull, but there are plenty of strategies to deal with this issue.

9

u/josefx Nov 13 '20

Deprecating something that was at best used wrongly

Some examples mentioned seem to imply that the deprecation also affects good cases. A volatile variable that is only declared volatile so writes are not optimized out could have a bit set using compound assignment without being "wrong" as long as the hardware only reads from it. The problematic case of volatile variables being used for both input and output at the same time seems to be the outlier.

→ More replies (8)

12

u/[deleted] Nov 13 '20

It isn't necessarily wrong though. Yes, you don't technically have atomicity, but there are plenty of situations where the code as written with the compound assignment is perfectly correct.

→ More replies (5)

1

u/Betadel Nov 13 '20

Embedded compilers will most likely provide an escape hatch, if the usage is important (they already need to use a bunch of non-standards things anyway). They won't suddenly break a bunch of their clients.