Ron Ford said:
No, I was engaging in hyperbole. I think of that which is
"volatile" to be opposed to that which is "safe." I've never used
this qualifier in my own code.
The English meaning of the term doesn't tell you much about what it
means in C. "volatile" is not the opposite of "safe" in this context.
So I spent some time with K&R, thinking I would there find the reason to
use the "volatile." Instaed I find §A8.2 in the footnote: "the const and
volatile properties are new with the ANSI standard. The purpose of const
.... The purpose of volatile is to force an implementation to suppress
optimization that could otherwise occur...."
If a program reads the value of a variable, and the compiler is able
to determine what its current value happens to be, it can generate
code that doesn't actually load the variable's value. For example:
...
int x = 42;
printf("x = %d\n", x);
...
The compiler can legitimately replace the printf() call with
puts("x = 42");
because it *knows* what the result of evaluating x would have been.
If x were qualified with "volatile", it would not be permitted to
perform that optimization.
The same applies to writes as well as reads.
I'm not really any closer than a half hour ago. What is the difference
between type specifiers and type qualifiers?
The latest draft of the standard is at
<
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf>.
It defines both terms, in 6.7.2 and 6.7.3, respectively.
The type specifiers are void, char, short, int, long, and so forth.
The type qualifiers are const, restrict, and volatile (restrict is new
in C99).