GCC warnings for unused global variables
Joe Buck
jbuck@synopsys.com
Fri May 9 18:04:00 GMT 2003
On Fri, May 09, 2003 at 10:29:39AM +0200, Gabriel Dos Reis wrote:
> Telling users that something has no well-defined semantics is
> part of educating users about what is practically portable. It is not
> frightening them.
Gaby, I disagree. You *are* likely to frighten users. volatile is a
needed feature, and your claim of "no well-defined semantics" is not accurate.
It is correct to claim that there are *aspects* of volatile where the
semantics are not well-defined, but there are other aspects that are
quite clear; specifically that the compiler cannot eliminate any reads
and writes that occur in the abstract machine. Precisely because of
the fact that volatile is designed to support access to the declared object
that cannot be "seen" by the compiler, the "as-if" rule cannot be used
to justify transformations.
There are many codes that rely on this feature, and for a GCC maintainer
to suggest that GCC might break such codes is scary. Embedded systems
programmers rely on this stuff.
In cases where there is doubt, GCC should (as it does now) err on the
side of doing no optimizations.
> My point is that volatile is so fuzzy that different people have
> different expectations of what it should do and any attempt of
> clafirication would not meet expectations of some people, would break
> some software written with another set of expectations in mind (if you
> look at the archive, you'll notice that everytime one touches
> volatile, it follows large (violent) debates); so probably
> the least bad thing to do is to do nothing.
EXACTLY.
More information about the Gcc
mailing list