https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95127
Bug ID: 95127 Summary: Self-calling lambda with auto return type gives misleading error message Product: gcc Version: 9.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xzlsmc at gmail dot com Target Milestone: --- $ cat bug.cc int main() { auto f = [](const auto &g, auto x) { return g(g, x); }; f(f, 0); } $ gcc -std=c++14 bug.cc bug.cc: In instantiation of ‘main()::<lambda(const auto:1&, auto:2)> [with auto:1 = main()::<lambda(const auto:1&, auto:2)>; auto:2 = int]’: bug.cc:3:9: required from here bug.cc:2:48: error: use of ‘main()::<lambda(const auto:1&, auto:2)> [with auto:1 = main()::<lambda(const auto:1&, auto:2)>; auto:2 = int]’ before deduction of ‘auto’ 2 | auto f = [](const auto &g, auto x) { return g(g, x); }; | ~^~~~~~ This error message is technically correct, but the `auto' it refers to is very misleading here: it's the implicit `auto' return type of the lambda expression, rather than either `auto' argument type. The message can become clearer if changed to "use of ... before deduction of _return type_". GCC version: 9.3.1