Fix a nasty bug with the partial destruction of nested arrays;
it escaped notice because it's only used for heterogeneous
initialization.
rdar://21397946
llvm-svn: 247597
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 587281c..6570785 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1535,9 +1535,9 @@
}
if (arrayDepth) {
- llvm::Value *zero = llvm::ConstantInt::get(CGF.SizeTy, arrayDepth+1);
+ llvm::Value *zero = llvm::ConstantInt::get(CGF.SizeTy, 0);
- SmallVector<llvm::Value*,4> gepIndices(arrayDepth, zero);
+ SmallVector<llvm::Value*,4> gepIndices(arrayDepth+1, zero);
begin = CGF.Builder.CreateInBoundsGEP(begin, gepIndices, "pad.arraybegin");
end = CGF.Builder.CreateInBoundsGEP(end, gepIndices, "pad.arrayend");
}