Why doesn't function declared inside other function participate in argument dependent lookup?
Consider a simple example: template <class T> struct tag { }; int main() { auto foo = [](auto x) -> decltype(bar(x)) { return {}; }; tag<int> bar(tag<int>); bar(tag<int>{}); // <- compiles OK foo(tag<int>{}); // 'bar' was not declared in this scope ?! } tag<int> bar(tag<int>) { return {}; } Both [gcc] and [clang] refuses to compile the code. Is this code ill-formed in some way? From unqualified lookup rules ([basic.lookup.unqual]): For the members of a class X , a name used in a member function body, [...], shall be declared in one of the following ways — if X is a local class or is a nested