volatiles

Eddie Wyatt edw at IUS1.CS.CMU.EDU
Thu Apr 14 07:07:27 AEST 1988


> 
> Programs that run successfully when unoptimized and fail when optimized
> suffer from one of the following:
> 	(1) The optimizer has bugs.
> 	(2) The program is incorrect, i.e. it is dependent on coincidental
> 	    or undefined behavior.

   And for the case of volatiles, it's my opinion that the optimization 
technique is buggy.  It assumes that data flow analysis of the code 
can be used to conduct dead code elimination, variable induction,
migration of loop invariants, etc.  It can not when you have multi-threads
of execution with shared variable because in general any of the shared
variables may changed at any time.  volatile is just a HACK to make the
optimization technique work!   volatile adds no additional expressive
power to the language, neither is it adding convenience - it only
tell the optimizer where it is about to goof up so the optimizer
doesn't commit a blunder!

-- 

Eddie Wyatt 				e-mail: edw at ius1.cs.cmu.edu



More information about the Comp.lang.c mailing list