diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 5a1516cf32af..b467dbc875c9 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -760,7 +760,13 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr, // Ignore empty classes in C++. if (getContext().getLangOptions().CPlusPlus) { if (const RecordType *RT = Ty->getAs()) { - if (cast(RT->getDecl())->isEmpty()) + CXXRecordDecl *Record = cast(RT->getDecl()); + assert((Record->hasTrivialCopyConstructor() || + Record->hasTrivialCopyAssignment() || + /*FIXME!*/getContext().getLangOptions().CPlusPlus) && + "Trying to aggregate-copy a type without a trivial copy " + "constructor or assignment operator"); + if (Record->isEmpty()) return; } }