Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.std.c Subject: Volatile (was Re: observability) Message-ID: <28993@news.Think.COM> Date: 7 Sep 89 21:17:23 GMT References: <1237@gmdzi.UUCP> <10885@smoke.BRL.MIL> <242@ssp1.idca.tds.philips.nl> <10937@smoke.BRL.MIL> <1989Sep6.160709.4890@light.uucp> <1989Sep6.183349.2866@jarvis.csri.toronto.edu> <28946@news.Think.COM> <857@skye.ed.ac.uk> Sender: news@Think.COM Reply-To: barmar@kulla.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 29 I think that I may have figured out what the earlier poster meant when he said that the effects of "volatile" aren't observable. When the volatile modifier is added to a variable, various constraints are placed on the implementation regarding the compilation of accesses to that variable. Conversely, removing the volatile modifier simply makes some operations implementation-dependent; I don't think it ever adds any constraints. Therefore, an implementation that treats all variables as if they were volatile would be valid. In such an implementation, adding and removing volatile modifiers would have no effect on the observable behavior of the program. An implementation could also randomly treat non-volatile variables as if they were volatile. During testing, the randomness might cause everything to work as the programmer wants. The point is that there's no reliable way to test whether the volatile modifier is ignored by an implementation. If a pair of programs which differr only in the use of volatile have the same observable effects, it could be accidental or it could be because it ignores the modifier. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar