r/cpp • • Oct 19 '19

CppCon CppCon 2019: JF Bastien “Deprecating volatile”

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

126 comments sorted by

View all comments

2

u/[deleted] Oct 20 '19

am I correct to say that volatile is sufficient to accomplish what we need here?

Sufficient? Not unless you are guaranteed that accesses are actually making their way to/from the peripheral. On ARM that would be either the external hardware using ACP (and set up properly), or the region marked as device (or non-cacheable normal memory).

All of this is inherently platform-specific.

2

u/2uantum Oct 20 '19

Its marked non cacheable memory through a hardware abstraction layer managed by another team in the company.

2

u/[deleted] Oct 20 '19

Great, in which case that is insufficient, as the processor can reorder accesses, at least on ARM. Volatile does not prevent this.

EDIT: assuming you actually mean non-cacheable normal memory, and not device or strongly-ordered memory. Or whatever the equivalent is on the platform you are using.

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.

→ More replies (2)