This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/41134] New: [4.5 regression] Variable flagges unused if only used in template function


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]