A question on volatile accesses
Ron Guilmette
rfg at lupine.ncd.com
Sat Nov 3 14:47:00 AEST 1990
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.
More information about the Comp.std.c
mailing list