volatile isn't necessary, but it's there

Doug Gwyn gwyn at brl-smoke.ARPA
Sun Apr 10 09:26:36 AEST 1988


In article <10988 at mimsy.UUCP> mangoe at mimsy.umd.edu.UUCP (Charley Wingate) writes:
>>Volatile is of use only with optimizing compilers; those that don't
>>do some kind of data-flow analysis can ignore it.  More bluntly,
>>it is intended to be used in cases where your compiler will do something
>>other than what your program plainly asks it to do.
>These statements only acquire truth because the default understanding of
>what the compiler ought to do is very very conservative and tends to reflect
>the most simple-minded way of understanding the code.

A programmer who is at all concerned with portability will code for
a "virtual machine", not for the current accidental hardware.  It is
extremely important that this virtual machine HAVE simple properties;
otherwise it becomes practically impossible to write correct code for
it.  Matters are somewhat confused in C because its virtual machine
has some properties that have deliberately fuzzy specifications; this
was intended to permit more efficient realizations of the virtual
machine on actual hardware, but it causes trouble when programmers
don't clearly understand this issue.



More information about the Comp.lang.c mailing list