Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!pacbell!ames!pasteur!ic.Berkeley.EDU!faustus From: faustus@ic.Berkeley.EDU (Wayne A. Christopher) Newsgroups: comp.lang.c Subject: Re: volatile Message-ID: <3732@pasteur.Berkeley.Edu> Date: 2 Jun 88 03:37:27 GMT Article-I.D.: pasteur.3732 References: <11783@mimsy.UUCP> <20345@pyramid.pyramid.com> <502@wsccs.UUCP> <51431@sun.uucp> <5590@bloom-beacon.MIT.EDU> Sender: news@pasteur.Berkeley.Edu Lines: 31 In article <11783@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: ] This last point---that C without `volatile' has been used for systems ] work---seems to have been ignored by those who claim that volatile is ] necessary. (Note that I claim only that it is unnecessary, not that it ] is bad.) It's unnecessary only if you don't want to optimize the code. The reason we've gotten by without it is that we haven't had good compilers. ] Let us try an experiment: ] ] f() { ] register int i, *ip; ] i = *ip; ] i = *ip; ] } ] ] produces ] ] movl (r10),r11 # i = *ip ] movl (r10),r11 # i = *ip ] ] That sure looks like the code I would expect from ] ] volatile int *ip; Only because you're using a bad compiler. I'll bet gcc would give you the results you expect. I don't think it makes any sense to declare an automatic variable volatile anyway. Wayne