[Bug c/12826] Optimizer removes reference through volatile pointer

falk dot hueffner at student dot uni-tuebingen dot de gcc-bugzilla@gcc.gnu.org
Wed Oct 29 16:28:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12826



------- Additional Comments From falk dot hueffner at student dot uni-tuebingen dot de  2003-10-29 16:18 -------
Subject: Re:  Optimizer removes reference through volatile pointer

"lee at bustech dot com" <gcc-bugzilla@gcc.gnu.org> writes:

> Thanks for your reply, cdecl gives me:
> 
> cdecl> explain volatile char *sp
> declare sp as pointer to volatile char
> 
> Which is what I want, a volatile char which should be read every
> time via sp. If I declare sp as "volatile char *" the code reads *sp
> as expected. It just seems that a cast should be equivalent to a
> declaration here...

It's not. Or would you also expect:

int x = 3, *p = &x;
f((const int *) p);
x = 4;

to be rejected by the compiler? As I said, it's the volatility of the
*object* that is relevant.

> P.S. Changing the assignment of "*sp = 0xE8" to "* (volatile char *)
> sp = 0xE8" also fixes the problem, which seems kind of odd.

I wouldn't rely on that.



More information about the Gcc-bugs mailing list