Index: clang/lib/Sema/SemaInit.cpp =================================================================== --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -5962,9 +5962,10 @@ if (Kind.getKind() == InitializationKind::IK_Direct || (Kind.getKind() == InitializationKind::IK_Copy && (Context.hasSameUnqualifiedType(SourceType, DestType) || - S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType)))) - TryConstructorInitialization(S, Entity, Kind, Args, - DestType, DestType, *this); + (Initializer && + S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType))))) + TryConstructorInitialization(S, Entity, Kind, Args, DestType, DestType, + *this); // - Otherwise (i.e., for the remaining copy-initialization cases), // user-defined conversion sequences that can convert from the source // type to the destination type or (when a conversion function is @@ -6027,8 +6028,8 @@ bool NeedAtomicConversion = false; if (const AtomicType *Atomic = DestType->getAs()) { if (Context.hasSameUnqualifiedType(SourceType, Atomic->getValueType()) || - S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, - Atomic->getValueType())) { + (Initializer && S.IsDerivedFrom(Initializer->getBeginLoc(), + SourceType, Atomic->getValueType())) { DestType = Atomic->getValueType(); NeedAtomicConversion = true; } @@ -6045,7 +6046,7 @@ // - Otherwise, if the initialization is direct-initialization, the source // type is std::nullptr_t, and the destination type is bool, the initial // value of the object being initialized is false. - if (!SourceType.isNull() && SourceType->isNullPtrType() && + if (!SourceType.isNull() && SourceType->isNullPtrType() && Initializer && DestType->isBooleanType() && Kind.getKind() == InitializationKind::IK_Direct) { AddConversionSequenceStep( @@ -6095,11 +6096,11 @@ DeclAccessPair dap; if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer)) { AddZeroInitializationStep(Entity.getType()); - } else if (Initializer->getType() == Context.OverloadTy && + } else if (Initializer && Initializer->getType() == Context.OverloadTy && !S.ResolveAddressOfOverloadedFunction(Initializer, DestType, false, dap)) SetFailed(InitializationSequence::FK_AddressOfOverloadFailed); - else if (Initializer->getType()->isFunctionType() && + else if (Initializer && Initializer->getType()->isFunctionType() && isExprAnUnaddressableFunction(S, Initializer)) SetFailed(InitializationSequence::FK_AddressOfUnaddressableFunction); else