3 ms·
How can a compiler remove a volatile store? There exists hardware where a store has a side effect, regardless of the value itself. For example, writing to a FIF
by Unklejoe 4y ago
How can a compiler remove a volatile store? There exists hardware where a store has a side effect, regardless of the value itself. For example, writing to a FIFO. That’s the entire point of volatile, no?
- ncmncm 4y agoYou may think so, and I may even agree. But those opinions do not control what compilers actually implement. For example, in void f() { volatile char sekrit[256]; sekrit[0] = 0; } a compiler may reason that, since sekrit is on the stack, and no hardware device could know where it is, it may elide the whole block. And, some do.