3 ms·
> Isn't it normal for compilers to just no-op functions that can be proved to have no side effects and no return values? Yes, which is why the volatile qualifi
by cbd1984 10y ago
> Isn't it normal for compilers to just no-op functions that can be proved to have no side effects and no return values?
Yes, which is why the volatile qualifier exists: It makes modifying specific variables a side-effect, which then cannot be optimized away.
- friendzis 10y agoNo, no, no. > 5.1.2.3 > 2 Accessing a volatile object <...> are all side effects. Yes, modifying is a form of access, but too is a read. Which means one can READ hardware register in a loop and expect it to change without compiler optimizing that out.
- cbd1984 10y agoNothing I said was wrong.