volatile

Ned Nowotny ned at ghostwheel.UUCP
Fri Apr 8 09:24:26 AEST 1988


Many people have claimed that "volatile" is necessary for a variety of
applications.  Every one of which has been successfully written at one
time or another.  Does this mean that all these signal handlers,
interrupt handlers, etc. are written in assembly or some other language?
I suppose it also means that those which are written in K&R C are
incorrect... Uh... completely unoptimizable.  (To -O or not to -O...)

In fact, why is it assumed that silent optimaztion of poorly (or,
perhaps, correctly) written code is desirable?  Just because a compiler
can be made smart enough to move a loop invariant out of a loop does not
mean that it is a good idea.  It makes more sense to just provide the
programmer with a warning.  If the code is incorrect, the programmer
learns something valuable.  If it is correct, the programmer may save
himself (or herself) a frustrating bout of debugging.

Optimizers should not do optimazations which can be expressed in the
source language itself.  However, if they recognize a possibly
poor construct, they should warn the programmer.  (At least until
automatic code generators can be made better programmers than your
typical Unix wizard.)

-- 

Ned Nowotny (ned at ghostwheel.aca.mcc.com.UUCP)



More information about the Comp.lang.c mailing list