summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp5
-rw-r--r--clang/test/CodeGenCXX/new.cpp7
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index a44dcf6f8bf..65018daff75 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -508,6 +508,11 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
return true;
}
+ // FindAllocationOverload can change the passed in arguments, so we need to
+ // copy them back.
+ if (NumPlaceArgs > 0)
+ std::copy(&AllocArgs[1], AllocArgs.end(), PlaceArgs);
+
// FIXME: This is leaked on error. But so much is currently in Sema that it's
// easier to clean it in one go.
AllocArgs[0]->Destroy(Context);
diff --git a/clang/test/CodeGenCXX/new.cpp b/clang/test/CodeGenCXX/new.cpp
index fddda2b5b5f..d07466db671 100644
--- a/clang/test/CodeGenCXX/new.cpp
+++ b/clang/test/CodeGenCXX/new.cpp
@@ -3,3 +3,10 @@
void t1() {
int* a = new int;
}
+
+// Placement.
+void* operator new(unsigned long, void*) throw();
+
+void t2(int* a) {
+ int* b = new (a) int;
+}
OpenPOWER on IntegriCloud