diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4492,7 +4492,8 @@ // Find expected alignment, and the actual alignment of the passed object. // getTypeAlignInChars requires complete types - if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType()) + if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() || + ParamTy->isUndeducedType() || ArgTy->isUndeducedType()) return; CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy); diff --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp --- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -543,6 +543,18 @@ int m = n; } +// Ensure we don't crash when CTAD fails. +template +struct Foo { // expected-note{{candidate function template not viable}} + Foo(T1, T2); // expected-note{{candidate function template not viable}} +}; + +template +void insert(Args &&...args); + +void foo() { + insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction guide}} +} #else // expected-no-diagnostics