Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!think!kulla!barmar From: barmar@kulla (Barry Margolin) Newsgroups: comp.std.c Subject: Re: volatile required? Message-ID: <30292@news.Think.COM> Date: 28 Sep 89 16:33:46 GMT References: <712@Aragorn.dde.dk> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 16 In article <712@Aragorn.dde.dk> ct@dde.dk (Claus Tondering) writes: > int p=3, *q=&p; > *q=4; > printf("%d\n",p); >Is it acceptable that this program prints 3 instead of 4? The variable >p is not declared volatile, and therefore the fact that *q=4 assigns >4 to p may be considered a side effect. No, the program must print 4. Since p's address is taken, the optimizer should know that it isn't safe to assume that only assignments to p will modify its value. Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar