https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85108
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Summary|[7/8 Regression] Incorrect |[7 Regression] Incorrect |warning for constexpr |warning for constexpr |lambda with |lambda with |-Wunused-but-set-variable |-Wunused-but-set-variable --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Testcase without includes: // 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; } With -std=c++17 -Wunused-but-set-variable we don't warn about this anymore starting with r253266. The testcase is rejected with -std=c++14 starting with r247814 aka PR70979 fix.