http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48581
Summary: [C++0x][SFINAE] Lack of ADL in default template argument types Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: daniel.krueg...@googlemail.com gcc 4.7 in C++0x mode rejects the following program, but accepts it, when the define USE_AS_RET_TYPE is activated by uncommenting: -------------- template<class T> T&& create(); //#define USE_AS_RET_TYPE #ifndef USE_AS_RET_TYPE template<class T, class = decltype(foo(create<T>())) > auto f(int) -> char; #else template<class T> auto f(int) -> decltype(foo(create<T>()), char()); #endif template<class> auto f(...) -> char (&)[2]; struct S {}; void foo(S); static_assert(sizeof(f<S>(0)) == 1, "Error"); // (#) int main() {} -------------- (#) "error: 'foo' was not declared in this scope" Instantiation of the f(int) overload should properly honor ADL because of the type-dependent expression as it does in the alternative form as part of the return type.