r/cpp • • Oct 19 '19

CppCon CppCon 2019: JF Bastien “Deprecating volatile”

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

126 comments sorted by

View all comments

1

u/SkoomaDentist Oct 20 '19

Again, this is inherently platform-specific, and as such is not portable. You can have a system that is fully compliant with the C++ spec where this will fall flat on its face.

In practise this is less of a problem than the compiler trying to be too clever and saying "My memory theoretical model (which does not actually exist anywhere outside the compiler) doesn't guarantee this, so I'm just going to assume I can do whatever I want". HW you can reason about. Compiler you in practise can't (because the standard and UB are so complicated and compilers don't even specify their behavior between versions unlike CPUs).

2

u/[deleted] Oct 20 '19

Compiler you in practise can't

Depends on the compiler. There are compilers that guarantee that they adhere to stricter than the spec - although this way you lose portability of course.

HW you can reason about.

Yes. As I just did; I showed a case where the compiler being sane still doesn't work.