Fix case where the alignment is overaligned, per Eli's suggestion.
rdar://11220251
llvm-svn: 154893
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index d345154..7b0e0f5 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -238,7 +238,10 @@
// Otherwise, do a final copy,
assert(Dest.getAddr() != Src.getAggregateAddr());
- EmitFinalDestCopy(E, Src, /*Ignore*/ true, Dest.getAlignment().getQuantity());
+ std::pair<CharUnits, CharUnits> TypeInfo =
+ CGF.getContext().getTypeInfoInChars(E->getType());
+ CharUnits Alignment = std::min(TypeInfo.second, Dest.getAlignment());
+ EmitFinalDestCopy(E, Src, /*Ignore*/ true, Alignment.getQuantity());
}
/// EmitFinalDestCopy - Perform the final copy to DestPtr, if desired.