[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
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];` ??



More information about the llvm-commits mailing list