This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Warnings about rcs_id strings: let's settle this
- From: "Kean Johnston" <jkj at sco dot com>
- To: "'Joseph S. Myers'" <jsm28 at cam dot ac dot uk>
- Cc: "'Zack Weinberg'" <zack at codesourcery dot com>,"'Joe Buck'" <jbuck at synopsys dot com>, <gcc at gcc dot gnu dot org>
- Date: Fri, 2 May 2003 14:06:56 -0700
- Subject: RE: Warnings about rcs_id strings: let's settle this
- Organization: The SCO Group
> Is this code not then riddled with other old practices that generate
> warnings, such as implicit int? Certainly *BSD have needed extensive
Trhat level of cleanup has been done. But we digress ...
> > What is the *HARM* in checking non-const.
>
> It would break things for anyone (not using -W/-Wextra)
> expecting unused
> variables to be detected by -Wall and -Wunused-variable, following the
> existing longstanding clear documentation of what
> -Wunused-variable does.
No sir. This is for static only. Let me explain with an example. This
is hand written not compiler generated, so if anyone wants to disagree
let it be on the concept not the wording.
cat foo.c
1 static const char sccsid[] = "string1";
2 static const char *rcsid = "string2";
3 static char oldsccsid[] = "string3";
4 static char oldrcsid* = "string4";
5 const char fooid[] = "string5";
6 const char *barid = "string6";
7
8 int baz (void)
9 {
10 static int frob = 0;
11 int boo = 3;
12 return 3;
13 }
gcc -Wall -c foo.c
foo.c:10: unused variable 'frob'
foo.c:11: unused variable 'boo'
gcc -Wall -Wunused-static-variable -c foo.c
foo.c:1: 'sccsid' defined but not used
foo.c:2: 'rcsid' defined but not used
foo.c:3: 'oldsccsid' defined but not used
foo.c:4: 'oldrcsid' defined but not used
foo.c:10: unused variable 'frob'
foo.c:11: unused variable 'boo'
Strangely enough, gcc 2.96.3 doesn't report sccsid as being used, but
does the other three global statics.
> I don't know how many people have such expectations, but if what
> -Wunused-variable does is to be changed then rather than
> making its name
> misleading by restricting it to local variables only it might
> make more
> sense for it to be an option that turns on -Wunused-local-variable and
> -Wunused-static-variable (both being new options, only the first in
> -Wall), so expanding rather than reducing what it does.
Now THAT is a sensible suggestion, because in effect, moving the checks
for unused statics behind a different warning option does exactly that,
it reduces -Wunused-variable to unused locals only, so the warning name
change is appropriate.
Its also really easy and quick to change and document, but I anticipate
some objections.
Kean