🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #615

Re: volatile required?

#615
From: Barry Margolin
Date: Thu, 28 Sep 1989 16:33
16 lines
952 bytes
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
Technical Details
Message-ID: <30292@news.Think.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!think!kulla!barmar
References: <712@Aragorn.dde.dk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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