This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37934] New: show a warning when a symbol is unused and completely removed from the output file
- From: "edwintorok at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Oct 2008 12:54:38 -0000
- Subject: [Bug c++/37934] New: show a warning when a symbol is unused and completely removed from the output file
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider the testcase below.
$ cat test.cpp
namespace x {
extern const char ** const foo;
extern const char ** const bar;
};
using namespace x;
namespace {
const char* X;
};
const char ** const foo = &X;
const char ** const x::bar = &X;
$ g++ test.cpp -Wall -Wunused -Wextra -c -o test.o
$ nm test.o | c++filt
0000000000000000 b (anonymous namespace)::X
0000000000000000 R x::bar
foo is completely removed from the output, and no warning is shown.
It would be useful to show a warning here.
For example in the above testcase I forgot to add the x:: namespace qualifier
to foo (the extern declaration was in a header and I didn't notice it was part
of a namespace).
Since I didn't get any warning, I got a linker error, and had to spend some
time tracing down this typo in my code.
Had I seen a warning from the compiler that 'foo' is not used
and will get removed I would have immediately noticed the absence of the x::
namespace qualifier.
--
Summary: show a warning when a symbol is unused and completely
removed from the output file
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: edwintorok at gmail dot com
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37934