This would appear to be a recent regression: ---------------------------- template <int> struct X { static const int s = 2; }; template <typename T> int f() { const unsigned int dim = 2; return X<dim>::s; } template int f<int>(); ----------------------------- deal.II> c++ -c -W -Wunused x.cc x.cc: In function 'int f() [with T = int]': x.cc:8:21: instantiated from here x.cc:4:22: warning: unused variable 'dim' 'dim' is used here, it just is never read from or written to. W.
Jason, might this be a result of your changes to used/unused variables? W.
*** This bug has been marked as a duplicate of 41109 ***
Subject: Bug 41110 Author: jason Date: Mon Aug 24 21:31:54 2009 New Revision: 151061 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151061 Log: PR c++/41109 PR c++/41110 PR c++/41134 * cp-tree.h (DECL_ODR_USED): New macro. (struct lang_decl_base): Add odr_used flag. * decl.c (duplicate_decls): Propagate it. Use it for error. * pt.c (register_specialization): Use it for error. * decl2.c (mark_used): Use it as gating flag rather than TREE_USED. (cp_write_global_declarations): Use it for error. (tree_used_ok): Remove. * cp-tree.h: Remove tree_used_ok. * call.c (build_call_a): Don't call it. * init.c (build_offset_ref): Likewise. Added: trunk/gcc/testsuite/g++.dg/warn/Wunused-17.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/cp/decl2.c trunk/gcc/cp/init.c trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog