This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/12826] Optimizer removes reference through volatile pointer
- From: "falk dot hueffner at student dot uni-tuebingen dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Oct 2003 16:18:46 -0000
- Subject: [Bug c/12826] Optimizer removes reference through volatile pointer
- References: <20031029145012.12826.lee@bustech.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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.