News for hackers. Stuff that matters.
Re:Essential C [pdf] by Thiez on Sunday March 06, 2022 @05:04PM (#30581741)
Volatile operations are considered a side effect and as such may not be reordered with other volatile operations. How is that not literally sufficient for the operations that GGP described?
Re:Essential C [pdf] by compiler-guy on Sunday March 06, 2022 @05:22PM (#30581864)
I spoke perhaps a little strongly. But that said:

The compiler is free to reorder accesses to multiple volatile variables if they happen prior to the same sequence point. So (roughly) expressions involving two volatile variables do not have those accesses sequenced.

But you are right that the usage described earlier is OK, as long as both variables are marked volatile, and the accesses straddle a sequence point.

The more common mistake with volatiles is to use the for multithreading primitives.