Article View: comp.std.c
Article #621Re: volatile required?
From: Doug Gwyn
Date: Thu, 28 Sep 1989 14:48
Date: Thu, 28 Sep 1989 14:48
11 lines
918 bytes
918 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, a correct implementation must print "4" (and a new-line).
You're confusing "volatile" with "noalias" (which is no longer
in the proposed standard). C supports aliasing via pointers.
Technical Details
Message-ID:
<11175@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwynReferences:
<712@Aragorn.dde.dk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: volatile required? Message-ID: <11175@smoke.BRL.MIL> Date: 28 Sep 89 14:48:37 GMT References: <712@Aragorn.dde.dk> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 11