volatile semantics

Richard Henderson rth@redhat.com
Sun Jul 17 16:18:00 GMT 2005


On Sun, Jul 17, 2005 at 05:03:55PM +0100, Nathan Sidwell wrote:
> Issue 1.
> void Foo (char *ptr) {
>   *(volatile char *)ptr;
> }
...
> char c;
> *(volatile char *)&c; // can this read be deleted?
...
> void Foo (volatile char *ptr) {
>   *(char *)ptr;

I did see Ian's summary,

  http://gcc.gnu.org/ml/gcc/2005-07/msg00714.html

wherein he ascribed the semantics of the volatile qualifier to the
access, and not to the object.  I agree with his description completely,
as I believe it embodies the intuition that C programmers have used
wrt these qualifiers since forever.

So the answers to the "deleteable" questions above are no, no, yes.

And it's probably a one-line bug in our "can this cast be removed"
function.


r~



More information about the Gcc mailing list