Path: 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 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.