[cfe-commits] r72673 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/CodeGenCXX/new.cpp

Anders Carlsson andersca at mac.com
Sun May 31 13:26:12 PDT 2009


Author: andersca
Date: Sun May 31 15:26:12 2009
New Revision: 72673

URL: http://llvm.org/viewvc/llvm-project?rev=72673&view=rev
Log:
Make sure to copy back arguments that can be changed by FindAllocationOverload. This fixes placement new. (Sebastian, please review).

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/CodeGenCXX/new.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=72673&r1=72672&r2=72673&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun May 31 15:26:12 2009
@@ -508,6 +508,11 @@
       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);

Modified: cfe/trunk/test/CodeGenCXX/new.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/new.cpp?rev=72673&r1=72672&r2=72673&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/new.cpp Sun May 31 15:26:12 2009
@@ -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;
+}





More information about the cfe-commits mailing list