diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -1573,7 +1573,7 @@ llvm::Value *allocSize = EmitCXXNewAllocSize(*this, E, minElements, numElements, allocSizeWithoutCookie); - CharUnits allocAlign = getContext().getPreferredTypeAlignInChars(allocType); + CharUnits allocAlign; // Emit the allocation call. If the allocator is a global placement // operator, just "inline" it directly. @@ -1583,6 +1583,8 @@ assert(E->getNumPlacementArgs() == 1); const Expr *arg = *E->placement_arguments().begin(); + allocAlign = getContext().getTypeAlignInChars(allocType); + LValueBaseInfo BaseInfo; allocation = EmitPointerWithAlignment(arg, &BaseInfo); @@ -1605,6 +1607,8 @@ allocator->getType()->castAs(); unsigned ParamsToSkip = 0; + allocAlign = getContext().getPreferredTypeAlignInChars(allocType); + // The allocation size is the first argument. QualType sizeType = getContext().getSizeType(); allocatorArgs.add(RValue::get(allocSize), sizeType);