Article View: comp.std.c
Article #1926A question on volatile accesses
From: Ron Guilmette
Date: Sat, 03 Nov 1990 03:47
Date: Sat, 03 Nov 1990 03:47
39 lines
1173 bytes
1173 bytes
Given the following code:
volatile int *ip;
void foobar ()
{
register int i;
do
i = *++ip;
while (i);
}
I'd like to know if the standard allows the incrementation of `ip'
to occur *after* the volatile access.
In other words, could the program above legally be treated as:
volatile int *ip;
void foobar ()
{
register int i;
do {
i = *ip;
++ip;
} while (i);
}
This seems entirely counter-intutive to me, and yet one supposedly ANSI
C compiler provides such a treatment.
I guess the question comes down to this: When you dereference a
pre-incremented pointer, can you always safely assume that the
pre-increment has already occured by the time the indirection
through the pointer occurs?
Note that the variable `ip' is not itself volatile.
Technical Details
Message-ID:
<2388@lupine.NCD.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!lupine!lupine.ncd.comShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!lupine!lupine.ncd.com From: rfg@lupine.ncd.com (Ron Guilmette) Newsgroups: comp.std.c Subject: A question on volatile accesses Message-ID: <2388@lupine.NCD.COM> Date: 3 Nov 90 03:47:00 GMT Sender: rfg@NCD.COM Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 39