diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 0e81804f8c1e7..ca5db61afbd2e 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1137,6 +1137,9 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) { // FIXME: For synthesized functions that are not defaulted, // produce a note. auto *FD = dyn_cast(Active->Entity); + // Note: if FD is nullptr currently setting DFK to DefaultedFunctionKind() + // will ensure that DFK.isComparison() is false. This is important because + // we will uncondtionally dereference FD in the else if. DefaultedFunctionKind DFK = FD ? getDefaultedFunctionKind(FD) : DefaultedFunctionKind(); if (DFK.isSpecialMember()) {