Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ucbvax!amdcad!rpw3 From: rpw3@amdcad.UUCP Newsgroups: comp.arch,comp.lang.c Subject: Re: Optimization vs. the programmer Message-ID: <16014@amdcad.AMD.COM> Date: Tue, 7-Apr-87 22:12:43 EST Article-I.D.: amdcad.16014 Posted: Tue Apr 7 22:12:43 1987 Date-Received: Sat, 11-Apr-87 03:34:45 EST References: <479@danews.ATT.COM> Reply-To: rpw3@amdcad.UUCP (Rob Warnock) Distribution: world Organization: [Consultant] San Mateo, CA Lines: 26 Xref: utgpu comp.arch:810 comp.lang.c:1515 Summary: Use "volatile" when needed In article <479@danews.ATT.COM> lvc@danews.ATT.COM (Larry Cipriani) writes: +--------------- | There is a certain computer (that I still use) that requires the statement: | n = n; | in order to force the hardware to work right for certain values of n... | If I had an optimizing compiler that was smart (?$!?) enough to excise this | I couldn't make the machine work right. +--------------- I can't agree. Instead, *tell* the compiler that you need to do this. In ANSI C (or any useful optimizing C compiler), simply say: volatile int n; ... n = n; And the compiler will *always* fetch & store "n" when referenced. Rob Warnock Systems Architecture Consultant UUCP: {amdcad,fortune,sun,attmail}!redwood!rpw3 ATTmail: !rpw3 DDD: (415)572-2607 USPS: 627 26th Ave, San Mateo, CA 94403