volatile

Chris Torek chris at mimsy.UUCP
Fri Apr 1 03:57:26 AEST 1988


-In article <9176 at tut.cis.ohio-state.edu> lvc at tut.cis.ohio-state.edu
-(Lawrence V. Cipriani) writes:
->	volatile int customer_changeable_var = 0;
->	if (customer_chageable_var != 0)
->[without something like volatile] the compiler would be free to
->optimize out the "impossible" code.

In article <18686 at think.UUCP> barmar at think.COM (Barry Margolin) writes:
-I don't think volatile is necessary for the above example.

and in article <4217 at ihlpf.ATT.COM> nevin1 at ihlpf.ATT.COM (00704a-Liber)
writes:
-The compiler would *not* be free to optimize out this code!!  Because
-customer_changeable_var is EXTERNAL to main(), this optimization cannot
-occur.

lvc is right; barmar and nevin1 are wrong.  Remember, compilation
need not take place until after everything is linked together.
Admittedly there are few (possibly no) compilers which would make
this `optimisation' today.  I expect this to change in the near
future.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list