[Bug c/28901] -Wunused-variable ignores unused const initialised variables
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jan 17 00:26:00 GMT 2014
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.
More information about the Gcc-bugs
mailing list