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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to