http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49339
Summary: [C++0x][lambda][unused-parameter]g++ reports unused parameter even it's referenced in function Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: len...@gmail.com I'm using ArchLinux with GCC 4.6.0 (20110603). $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: /build/src/gcc-4.6-20110603/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --disable-multilib --disable-libstdcxx-pch --enable-checking=release Thread model: posix gcc version 4.6.0 20110603 (prerelease) (GCC) When compiling following codes #include <algorithm> #include <vector> #include <memory> #include <iostream> template <typename _RawType> void append(std::vector<_RawType>& former, std::vector<_RawType>&& latter) { std::for_each(latter.begin() , latter.end() , [&](_RawType& x) { former.push_back(std::move(x)); }); } int main(void) { std::vector<int> aa; append(aa, std::vector<int>()); return 0; } with g++ % -Wunused-parameter -std=c++0x g++ prints unused-param.cpp: In instantiation of ‘append(std::vector<_RealType>&, std::vector<_RealType>&&) [with _RawType = int]::<lambda(int&)>’: unused-param.cpp:9:5: instantiated from ‘void append(std::vector<_RealType>&, std::vector<_RealType>&&) [with _RawType = int]’ unused-param.cpp:20:34: instantiated from here unused-param.cpp:11:34: warning: unused parameter ‘x’ [-Wunused-parameter] but `x` is referenced in line 13 ("former.push_back(std::move(x));").