Hi! This got fixed with r253266, but I don't see it covered with a testcase. Tested on x86_64-linux and i686-linux, committed to trunk as obvious.
2018-03-29 Jakub Jelinek <ja...@redhat.com> PR c++/85108 * g++.dg/warn/Wunused-var-31.C: New test. --- gcc/testsuite/g++.dg/warn/Wunused-var-31.C.jj 2018-03-29 13:15:26.433012694 +0200 +++ gcc/testsuite/g++.dg/warn/Wunused-var-31.C 2018-03-29 13:09:48.184877285 +0200 @@ -0,0 +1,11 @@ +// PR c++/85108 +// { dg-do compile { target c++17 } } +// { dg-options "-Wunused-but-set-variable" } + +int +main () +{ + auto constexpr add = [] (auto a, auto b) { return a + b; }; // { dg-bogus "set but not used" } + auto test_lambda = [&] () { return add (2, 2); }; + return test_lambda () - 4; +} Jakub