volatile [was: GCC warnings for unused global variables]

Fergus Henderson fjh@cs.mu.OZ.AU
Thu May 8 16:44:00 GMT 2003


On 08-May-2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> Fergus Henderson <fjh@cs.mu.OZ.AU> writes:
> 
> [...]
> 
> | (This belief is not based on any specific statements of the C committee
> | members, but rather on the general principles that they're not idiots
>                                                              ^^^^^^^^^^
> | and that they intended the words that they wrote to be meaningful.)
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Not just because what the committee came to specify is fuzzy,
> contradictory to the best means that the committee members were idiots.

What I'm saying is that if there are two possible interpretations,
and one of them makes sense, and the other would only make sense
if the C committee were idiots, then I choose the former.

Sorry, that is really an unnecessarily inflammatory way of saying it.
I just mean that if one interpretation is internally inconsistent,
and the other is not, then I choose the one which is not.

So let me try to explain why I think your interpretation is contradictory.
Your interpretation allows implementations to optimize away accesses to
volatile variables, which seems to contradict the statement in 6.7.3
paragraph one that expressions involving volatile shall be evaluated
"strictly in accordance with the rules of the abstract machine".  I don't
see how you can resolve that contradiction.

My interpretation only requires assuming that a conforming
implementation is not allowed to deduce that side effects
due to accesses to volatile variables are not needed.
That seems like a perfectly reasonable assumption,
given that 6.7.3 already says almost exactly that.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.



More information about the Gcc mailing list