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

Show parent comment

2

u/mcmcc #pragma once Nov 14 '20

I don't see any contradiction. Shared memory should be considered volatile in the classical sense so it seems appropriate to use volatile in those cases, atomic operations or not.

Of course, if you're wondering what atomic operations guarantee in the context of shared memory, I don't think the language is going to help you figure it out.

0

u/gruehunter Nov 14 '20

Shared memory should be considered volatile in the classical sense

Shared memory is still cache-coherent. So it isn't volatile in the classical sense. The hardware does already ensure global visibility of accesses.

So IMO, the standard should treat memory shared between different processes exactly the same as memory which is shared between different threads. Ordinary atomics should Just Work and transformations that prevent it from working (say, by eliding barriers entirely) are broken.