]> granicus.if.org Git - clang/commitdiff
Make sure to copy back arguments that can be changed by FindAllocationOverload. This...
authorAnders Carlsson <andersca@mac.com>
Sun, 31 May 2009 20:26:12 +0000 (20:26 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 31 May 2009 20:26:12 +0000 (20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72673 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/CodeGenCXX/new.cpp

index a44dcf6f8bf505310e9ed8bff03ee12e3b4dd58f..65018daff75b24253c6463680760ba027f63f8cc 100644 (file)
@@ -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);
index fddda2b5b5f323c98dddd36d4d194b80dbf8c35f..d07466db6715bae6ae467c75661da9d78805a02a 100644 (file)
@@ -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;
+}