diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -12853,7 +12853,7 @@ if (Candidate.Function->isInvalidDecl()) return; QualType T = Candidate.Function->getReturnType(); - if (T.isNull()) + if (T.isNull() || T->isUndeducedType()) return; if (!Result) Result = T; diff --git a/clang/test/SemaCXX/recovery-expr-type.cpp b/clang/test/SemaCXX/recovery-expr-type.cpp --- a/clang/test/SemaCXX/recovery-expr-type.cpp +++ b/clang/test/SemaCXX/recovery-expr-type.cpp @@ -105,3 +105,9 @@ int v = arr(); // expected-error {{array types cannot be value-initialized}} \ expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}} } + +namespace test9 { +auto f(); // expected-note {{candidate function not viable}} +// verify no crash on evaluating the size of undeduced auto type. +static_assert(sizeof(f(1)), ""); // expected-error {{no matching function for call to 'f'}} +}