This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: volatile semantics



On May 5, 2005, at 5:23 AM, Kai Henningsen wrote:
nathan@codesourcery.com (Nathan Sidwell) wrote on 03.05.05 in <42778D99.7070904@codesourcery.com>:
Mike Stump wrote:
int avail;
int main() {
  while (*(volatile int *)&avail == 0)
    continue;
  return 0;
}


Ok, so, the question is, should gcc produce code that infinitely loops,
or should it be obligated to actually fetch from memory? Hint, 3.3
fetched.

I beleive the compiler is so licensed. [5.1.2.3/2] talks about accessing
a volatile object. If the compiled can determine the actual object
being accessed through a series of pointer and volatile cast conversions,
then I see nothing in the std saying it must behave as-if the object
were volatile when it is not.


This, of course, might not be useful to users :)

As a QOI issue, it would be nice if such a situation caused a warning ("ignoring volatile cast ..." or something like that).

It's rather dangerous to have the user believe that this worked as
intended when it didn't.

If we aren't going to make this work as obviously intended, and the sentiment
seems to be against it, then this is certainly a good idea.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]