This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'Mike Stump'" <mrs at apple dot com>, "'Richard Earnshaw'" <rearnsha at gcc dot gnu dot org>
- Cc: "'Ian Lance Taylor'" <ian at airs dot com>, <gcc at gcc dot gnu dot org>
- Date: Mon, 28 Nov 2005 17:29:16 -0000
- Subject: RE: Why doesn't combine like volatiles? (volatile_ok again, sorry!)
Mike Stump wrote:
> On Nov 28, 2005, at 3:00 AM, Richard Earnshaw wrote:
>> Possibly, but I think the more interesting observation is listed in
>> parenthesis: Can a volatile access ever alias a non-volatile access?
>> Logic would suggest that a program is unpredictable if written in such a
>> way that permits such aliases to exist, since it would mean a location
>> is being accessed in both non-volatile and volatile manner.
>
> I think this is uninteresting, as I'd presume that it is valid, and
> the user really wanted to do it (the below is pseudo code, no, really):
>
> int i[4096];
>
> void foo() {
> i[0] = 0;
> mmap (... &i[0], ...);
> (*(volatile int *)&i[0]) = 1;
> }
>
> Anyway, why it is uninteresting is, the normal rules say they alias,
> so they alias. And for people that just want to quote the standard,
> don't bother, let me:
>
> [#5] If an attempt is made to modify an object defined with
> a const-qualified type through use of an lvalue with non-
> const-qualified type, the behavior is undefined. If an
> attempt is made to refer to an object defined with a
> volatile-qualified type through use of an lvalue with non-
> volatile-qualified type, the behavior is undefined.102)
:) I seem to remember this case having come up in a very long thread
earlier this year, when we were discussing whether what was relevant was the
actual type and quals of the object being accessed, or the type and quals of
the decl/pointer through which it was being accessed.
And all of this is quite a way off from where I came in. We're worrying
about moving accesses past each other, and aliasing, and so on. All I ever
wanted to do was combine a *single* volatile access with an
immediately-consecutive ALU operation on the result of that volatile access.
BTW, I never did manage to find the patches you referred to in your postings
from summer 2000. Googling for "mike stump volatile_ok" just kept on finding
me the post where you were advising someone to find your patches by searching
for your name and volatile_ok. Kinda recursive, that.... do you still have a
pointer to them?
cheers,
DaveK
--
Can't think of a witty .sigline today....