Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pacbell!att-ih!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: volatile Message-ID: <4217@ihlpf.ATT.COM> Date: 31 Mar 88 01:33:29 GMT References: <12578@brl-adm.ARPA> <1988Mar25.172355.348@utzoo.uucp> <588@imagine.PAWL.RPI.EDU> <1988Mar29.004454.2867@utzoo.uucp> <134@wyse.wyse.com> <9176@tut.cis.ohio-state.edu> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 28 In article <9176@tut.cis.ohio-state.edu> lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes: |I might not understand volatile correctly but this might also be an |example: | | volatile int customer_changeable_var = 0; | | main( ) | ... | | if (customer_chageable_var != 0) | { | ... | } | |If the volatile were dropped off, the compiler would be free to |optimize out the "impossible" code. The compiler would *not* be free to optimize out this code!! Because customer_changeable_var is EXTERNAL to main(), this optimization cannot occur. The fact that it is declared 'volatile' is irrelevant (unless you are saying that the customer should be able to change the variable directly by toggling a hardwired switch which is directly mapped to the memory location at which customer_changeable_var is stored. But this case is non-portable, and the previously posted arguments apply). -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_