This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC warnings for unused global variables
Joe Buck <jbuck@synopsys.com> writes:
> On Thu, May 01, 2003 at 07:05:08AM -0400, Robert Dewar wrote:
> > > And warning on perfectly legal, innocuous constructs makes
> > > absolutely no sense to me.
> >
> > Well all warnings apply to legal constructs, or they would be errors!
>
> > As to innocuous, the reason why something is NOT an error is that you
> > can't tell whether it is innocous or not, so warnings almost always
> > generate some false positives (or they would not be warnings!)
>
> Correct, but in this case, we've broken a 20-year-old convention.
> "Broken", that is, because we've carefully designed -Wall so that
> we can expect that high-quality software development processes can
> produce their code with -Wall -Werror.
This is still the case; it's easy to suppress the warning by adding an
appropriate attribute, or by use of 'volatile' (at least, I hope
'volatile' works, if not it can be fixed).
> > In this case, it is not clear what you are suggesting, to remove all
> > warnings in this situation would certainly remove some very useful
> > warnings.
>
> The suggestion should be clear: we have, in effect, introduced a regression.
> We should not be warning for unused constant strings, precisely because
> the existence of such strings is part of the de-facto standard SCCS/RCS
> coding convention.
It is not, and has never been, the case that -Wall is a flag that
always produces the same set of warnings on the same source code.
Those who want to use -Wall and want to have no warnings have to
realise that they will need to change their code with each new
compiler release as the compiler is enhanced to detect new
questionable constructs. Such new warnings are not regressions, they
are progressions.
--
- Geoffrey Keating <geoffk@geoffk.org>