This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41134] New: [4.5 regression] Variable flagges unused if only used in template function
- From: "bangerth at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Aug 2009 20:43:57 -0000
- Subject: [Bug c++/41134] New: [4.5 regression] Variable flagges unused if only used in template function
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here's yet another case of a variable that is flagged as unused when it is
actually referenced. I agree that this is a corner case: the variable
really *is* unused, the template function is not instantiated after all.
That said, this is not an uncommon idiom, the code is extracted from the
Threading Building Blocks library.
-------------------------------
static int i;
template <typename> int f() { return i; }
----------------------------------
deal.II> c++ -W -Wunused -c x.cc
x.cc:1:12: warning: 'i' defined but not used
W.
--
Summary: [4.5 regression] Variable flagges unused if only used in
template function
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bangerth at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41134