This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/28901] -Wunused-variable ignores unused const initialised variables
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 17 Jan 2014 00:26:51 +0000
- Subject: [Bug c/28901] -Wunused-variable ignores unused const initialised variables
- Auto-submitted: auto-generated
- References: <bug-28901-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28901
--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> From the code:
> /* We don't warn about "static const" variables because the
> "rcs_id" idiom uses that construction. */
That is not a good reason not to warn:
[hjl@gnu-mic-2 gcc]$ cat /tmp/w.c
static const int foo[0x1000];
[hjl@gnu-mic-2 gcc]$ gcc -Wall -S /tmp/w.c
[hjl@gnu-mic-2 gcc]$ cat w.s
.file "w.c"
.local foo
.comm foo,16384,32
.ident "GCC: (GNU) 4.8.2 20140115 (Red Hat 4.8.2-11)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-mic-2 gcc]$
If we want to avoid rcs_id warning, we can check it explicitly and
not to warn it.