@@ -12938,7 +12938,8 @@ tsubst_copy_and_build (tree t,
&& !any_type_dependent_arguments_p (call_args))
function = perform_koenig_lookup (function, call_args, false);
- if (TREE_CODE (function) == IDENTIFIER_NODE)
+ if (TREE_CODE (function) == IDENTIFIER_NODE
+ && !processing_template_decl)
{
unqualified_name_lookup_error (function);
release_tree_vector (call_args);
new file mode 100644
@@ -0,0 +1,20 @@
+// PR c++/48581
+// { dg-options -std=c++0x }
+
+template<class T>
+T&& create();
+
+template<class T,
+ class = decltype(foo(create<T>()))
+>
+auto f(int) -> char;
+
+template<class>
+auto f(...) -> char (&)[2];
+
+struct S {};
+void foo(S);
+
+static_assert(sizeof(f<S>(0)) == 1, "Error"); // (#)
+
+int main() {}