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 17:11:59 -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 17:11 -------
Subject: Re: Optimizer removes reference through volatile pointer
"lee at bustech dot com" <gcc-bugzilla@gcc.gnu.org> writes:
> > ... you are accessing a non-volatile object through a pointer to a
> > volatile char. That doesn't change the non-volatility of the
> > object
>
> But it does change the object's volatility to change the assignment of "*sp =
> 0xE8" to "* (volatile char *) sp = 0xE8". Gcc should at least be consistent
> here, it seems...
It doesn't change the object's volatility; it only inhibits an
optimization. The optimizers don't work well in the presence of
volatile, and in this particular case, I don't believe it's worth
improving them.
> > As I said, it's the volatility of the *object* that is relevant.
>
> I'm not sure what you mean here, the char is what I want to be
> volatile, and the cast seems to express that for me.
But it doesn't, as I've explained. Why didn't the example with "const"
convince you?