The following code triggers a "unused but set variable" warning on GCC trunk: int main() { auto f = []() { }; [=](auto) { using Foo = decltype(f()); }; } I think it is a false positive, since `f` is obviously used. > g++ --version g++ (GCC) 6.0.0 20150613 (experimental) > g++ -std=c++14 worksheet.cpp -fsyntax-only -Wall -Wno-unused-local-typedefs In function ‘int main()’: warning: variable ‘f’ set but not used [-Wunused-but-set-variable] auto f = []() { }; ^ Regards, Louis Dionne
Confirmed.
Created attachment 37873 [details] patch for after gcc 6
Author: jason Date: Tue Apr 19 19:30:22 2016 New Revision: 235221 URL: https://gcc.gnu.org/viewcvs?rev=235221&root=gcc&view=rev Log: PR c++/66543 - -Wunused-but-set* false positives * expr.c (mark_exp_read): Handle NON_DEPENDENT_EXPR. * pt.c (make_pack_expansion): Call mark_exp_read. * semantics.c (finish_id_expression): Call mark_type_use in unevaluated context. Added: trunk/gcc/testsuite/g++.dg/warn/Wunused-parm-7.C trunk/gcc/testsuite/g++.dg/warn/Wunused-parm-8.C trunk/gcc/testsuite/g++.dg/warn/Wunused-var-24.C trunk/gcc/testsuite/g++.dg/warn/Wunused-var-25.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/expr.c trunk/gcc/cp/pt.c trunk/gcc/cp/semantics.c
Author: jason Date: Wed Apr 20 13:24:17 2016 New Revision: 235279 URL: https://gcc.gnu.org/viewcvs?rev=235279&root=gcc&view=rev Log: PR c++/66543 - -Wunused-but-set* false positives * expr.c (mark_exp_read): Handle NON_DEPENDENT_EXPR. * pt.c (make_pack_expansion): Call mark_exp_read. * semantics.c (finish_id_expression): Call mark_type_use in unevaluated context. Added: branches/gcc-6-branch/gcc/testsuite/g++.dg/warn/Wunused-parm-7.C branches/gcc-6-branch/gcc/testsuite/g++.dg/warn/Wunused-parm-8.C branches/gcc-6-branch/gcc/testsuite/g++.dg/warn/Wunused-var-24.C branches/gcc-6-branch/gcc/testsuite/g++.dg/warn/Wunused-var-25.C Modified: branches/gcc-6-branch/gcc/cp/ChangeLog branches/gcc-6-branch/gcc/cp/expr.c branches/gcc-6-branch/gcc/cp/pt.c branches/gcc-6-branch/gcc/cp/semantics.c
Fixed for GCC 6.