[PATCH] More on adding sized deallocation functions in libc++

Marshall Clow mclow.lists at gmail.com
Tue Feb 17 21:01:35 PST 2015


================
Comment at: src/new.cpp:134
@@ -133,2 +133,3 @@
 
+#if _LIBCPP_STD_VER >= 14
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
----------------
rsmith wrote:
> Remove this `#if`/`#endif` pair and define the weak version unconditionally. The contents of the standard library should not depend on the `-std=` flag passed when bulding it. Because this function is weak, this won't break valid C++11 and earlier code that happens to be defining such a function.
Exactly correct. There should be no requirement to coordinate the `-std=` flag used to build the library and the flag used to build programs that use the library.


================
Comment at: test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_nothrow.pass.cpp:29
@@ +28,3 @@
+  ++delete_called;
+  std::free(p);
+}
----------------
rsmith wrote:
> It's questionable to assume that memory allocated by libc++'s `operator new` can be freed by `std::free`. I would suggest either replacing `operator new[]` too, or just leaking the memory.
I would prefer replacing `operator new[]` as well.

================
Comment at: test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_nothrow.pass.cpp:48
@@ +47,3 @@
+{
+    A* ap = new A(std::nothrow) [3];
+    assert(ap);
----------------
Shouldn't this be `A* ap = new (std::nothrow) A [3];` ??

http://reviews.llvm.org/D7707

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list