Index: include/clang/AST/TemplateBase.h =================================================================== --- include/clang/AST/TemplateBase.h +++ include/clang/AST/TemplateBase.h @@ -465,7 +465,14 @@ TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E) : Argument(Argument), LocInfo(E) { - assert(Argument.getKind() == TemplateArgument::Expression); + + /* When an error occurs in a template value that is defaulted to + nullptr then the nullptr is left as-is and this function will + take in an argument that is of type NullPtr when compiled using + C++17 standard. This is to make sure the compiler does not crash + and proceeds through. */ + assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument &Argument, Index: test/SemaObjCXX/class-templ-error-null-init.mm =================================================================== --- /dev/null +++ test/SemaObjCXX/class-templ-error-null-init.mm @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s + +template // expected-error {{unknown type name 'd'}} +class e { + public: + e(a,b) {} +}; + e c([]{} ,[]{} );