[libcxx-commits] [PATCH] D150408: [libc++] Complete refactor of tests for operator new

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 15 14:22:54 PDT 2023


philnik accepted this revision.
philnik added a comment.
This revision is now accepted and ready to land.

LGTM % possible test case and green CI.



================
Comment at: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size.replace.indirect.pass.cpp:29
+TEST_WORKAROUND_BUG_109234844_WEAK
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc) {
     ++new_called;
----------------
ldionne wrote:
> philnik wrote:
> > Are you allowed to override only operator new //or// operator delete? It yes, we might want to add a test for that.
> I don't think so, because the memory allocated with one has to be deallocated with the other. They need to use a mechanism that matches. For example, if your custom `operator new` uses `malloc` and the system-provided `operator delete` happens to use `free`, that's fine. But that might not be the case in general, the exact mechanism isn't specified.
Yes, but a user could define `operator new`, `operator delete` and `operator new[]`. There would still be a mismatch, but the user knows how `new` and `delete` allocate memory.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150408/new/

https://reviews.llvm.org/D150408



More information about the libcxx-commits mailing list