News for hackers. Stuff that matters.
Re:Everything in C is undefined behavior by mananaysiempre on Wednesday May 20, 2026 @06:05AM (#48205424)
Not from the standard’s point of view. The traditional (in some circles) use of volatile for atomic variables was not sanctioned by the C11/C++11 thread model; if you want an atomic, write atomic, not volatile, or be aware of your dependency on a compiler (like MSVC) that explicitly amends the language definition so as to allow cross-thread access to volatile variables.
Re:Everything in C is undefined behavior by sethev on Wednesday May 20, 2026 @06:11AM (#48205454)
Thread was a poor choice of word. Outside the control of the program is a better way to put it. Like memory mapped io.
Re:Everything in C is undefined behavior by surajrmal on Wednesday May 20, 2026 @11:14AM (#48209172)
It's almost universally better to use inline assembly via a macro to read/write mmio rather than use volatile.