The trouble with volatile
Posted May 15, 2007 9:15 UTC (Tue) by
IkeTo (subscriber, #2122)
In reply to:
The trouble with volatile by jzbiciak
Parent article:
The trouble with volatile
I think the original response says the following simpler code will cause a store plus load:
volatile int a;
void f() {
a = 2;
}
The argument is that "a = 2" has a value which requires a load to find, and the compiler is forbidden from optimizing out that load. I don't think the code generated by my 4.1.1 gcc reflects this, however:
movl $2, a
ret
So perhaps the OP is speaking from a rather old experience or a different compiler.
(
Log in to post comments)