https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112354
Bug ID: 112354 Summary: mismatched types 'B<T>' and 'B<int>&' for generic lambda noexcept-specifier referencing enclosing function parameter Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ed at catmur dot uk Target Milestone: --- Since 4.9.0, template<class> struct B { B(); B(B const&); }; template<class T> void g(B<T>, int); auto f(B<int> x) { return [](auto y) noexcept(noexcept(g(x, y))) { return 1; }; } int i = f({})(0); fails with: <source>: In instantiation of 'f(B<int>)::<lambda(auto:1)> [with auto:1 = int]': <source>:12:14: required from here 12 | int i = f({})(0); | ~~~~~^~~ <source>:8:42: error: no matching function for call to 'g(B<int>&&, int&)' 8 | return [](auto y) noexcept(noexcept(g(x, y))) { | ~^~~~~~ <source>:6:24: note: candidate: 'template<class T> void g(B<T>, int)' 6 | template<class T> void g(B<T>, int); | ^ <source>:6:24: note: template argument deduction/substitution failed: <source>:8:42: note: mismatched types 'B<T>' and 'B<int>&' 8 | return [](auto y) noexcept(noexcept(g(x, y))) { | ~^~~~~~