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: Zack Weinberg <zack at codesourcery dot com>
- To: "Kean Johnston" <jkj at sco dot com>
- Cc: "'Joe Buck'" <jbuck at synopsys dot com>, <gcc at gcc dot gnu dot org>
- Date: Fri, 02 May 2003 11:34:58 -0700
- Subject: Re: Warnings about rcs_id strings: let's settle this
- References: <009301c310d6$b0e3f100$03419384@shrike>
"Kean Johnston" <jkj@sco.com> writes:
> I too agree. I've read the whole thread, and had some other
> discussions about the patch, and here's what I'm about to change it
> to do. I'd like a nod from Joe, Gaby and you Zack, at the very least
> before I go charging off into vim-land again.
>
> 1) -Wall will NOT turn on -Wunused-static-variable
> 2) -Wextra WILL turn on -Wunused-static-variable
> 3) -Wunused-static-variable disappears out of c-opts.c and stays only
> in flags.h and toplev.c
This all looks good.
> And now, for the hard decision ... do I make the code check for const
> variables only? I vote not, if for no other reason than the original
> construct that spawned this thread was almost always written as
> static char *sccsid = "blah";.
Right, but to reiterate, GCC has warned about *that* construct since
forever; anyone using -Wall would have had problems already.
$ cat test.c
static char *sccsid = "blah";
$ gcc-2.95 -c -Wall test.c
test.c:1: warning: `sccsid' defined but not used
> By the way, why does THAT not emit a warning? You are assigning a
> const char * to a char *, thereby potentially losing the const-ness
> of it. I just tried with the head version and -Wall -Wextra
> -Wcast-qual didn't emit a warning.
The C compiler gives string literals type char[], not const char[],
unless -Wwrite-strings is used. (Turning this on is encouraged, but
will probably produce a cascade of additions of const-qualifiers all
over the program.)
They do get type const char[] in C++.
zw