[LLVMbugs] [Bug 12153] New: Incorrect warning about unused parameter when using capturing variadic parameter in lambda

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 1 09:31:37 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=12153

             Bug #: 12153
           Summary: Incorrect warning about unused parameter when using
                    capturing variadic parameter in lambda
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jonathan.sauer at gmx.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Compiling the following program with clang r151811 results in a warning about
the unused parameter 't':

template <typename... T>
static int count(T... t)
{
  auto l = [t...]() { return sizeof...(t); };
  return l();
}

$ $ ~/LLVM/build/Release+Asserts/bin/clang++ -std=c++0x -c -Wunused-parameter
-v clang.cpp 
clang version 3.1 (trunk 151811)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
[...]
clang.cpp:2:23: warning: unused parameter 't' [-Wunused-parameter]
static int count(T... t)
                      ^
1 warning generated.


The warning does not occur when 't' is not a variadic template parameter (the
two programs are not equivalent, of course):

template <typename T>
static int count(T t)
{
  auto l = [&t]() { return sizeof(t); };
  return l();
}


Incidentally I was wondering when exactly in this case 't' would count as being
used: When captured by a lambda but not used in the lambda, or when captured
*and* used by a lambda? And should capturing a variable but not using it also
result in a warning? (currently it doesn't)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list