Answer by supercat for Can volatile variables be read multiple times between...
The Standard has no terminology more specific than "Undefined Behavior" to describe actions which should be unambiguously defined on some implementations, or even the vast majority of them, but may...
View ArticleAnswer by Toby Speight for Can volatile variables be read multiple times...
No diagnostic is required for programs with Undefined Behaviour, except where specifically mentioned. So it's not wrong to accept this code.In general, it's not possible to know whether the same...
View ArticleAnswer by Steve Summit for Can volatile variables be read multiple times...
As other answers have pointed out, accessing a volatile-qualified variable is a side effect, and side effects are interesting, and having multiple side effects between sequence points is especially...
View ArticleAnswer by Lundin for Can volatile variables be read multiple times between...
Reading the (ISO 9899:2018) standard literally, then it is undefined behavior.C17 5.1.2.3/2 - definition of side effects:Accessing a volatile object, modifying an object, modifying a file, or calling a...
View ArticleAnswer by Andrew Henle for Can volatile variables be read multiple times...
Per C11, this is undefined behavior.Per 5.1.2.3 Program execution, paragraph 2 (bolding mine):Accessing a volatile object, modifying an object, modifying a file, or calling a function that does any of...
View ArticleAnswer by 0___________ for Can volatile variables be read multiple times...
IMO it is legal but very bad. int new_thing = thingy - (thingy + thingy);Multiple use of volatile variables in one expression is allowed and no warning is needed. But from the programmer's point of...
View ArticleCan volatile variables be read multiple times between sequence points?
I'm making my own C compiler to try to learn as much details as possible about C. I'm now trying to understand exactly how volatile objects work.What is confusing is that, every read access in the code...
View Article