[libcxx-commits] [PATCH] D57455: [libunwind] Provide inline placement new definition

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 1 13:11:23 PST 2019


ldionne added a comment.

In D57455#1377727 <https://reviews.llvm.org/D57455#1377727>, @mclow.lists wrote:

> Turns out the placement versions of new are not replaceable, so what I said about UB is just wrong.
>
> However, In [new.delete.placement]/3, it says: These functions are reserved, a C++ program may not define functions that displace the versions in the Standard C++ library (17.6.4).


In other words, the only Standard-blessed way of doing this is to `#include <new>` and use the definition inside the Standard library.

A way of achieving the same effect would be to define the same thing thats in `<new>`, like:

  _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new  (std::size_t, void* __p) _NOEXCEPT {return __p;}
  _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}

I'll admit I dislike all the solutions here. Also it means there's no such thing as C++ without its standard library, which I didn't think of before.

If Marshall is OK with that, I'd suggest going with the proposed patch but adding a note that this isn't technically Standards-conforming. Otherwise, the only solution I see is to re-introduce a dependency on the libc++ headers (which might not be so bad after all because we really need a separate concept of libc++ headers and libc++ runtime library anyway).


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D57455





More information about the libcxx-commits mailing list