[libcxx-commits] [PATCH] D110846: [libcxx] Make allocator<T>:allocate throw bad_array_new_length

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 4 10:22:00 PDT 2021


ldionne added inline comments.


================
Comment at: libcxx/include/new:151
 _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc();  // not in C++ spec
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __libcpp_throw_bad_array_new_length();
 
----------------
miyuki wrote:
> miyuki wrote:
> > ldionne wrote:
> > > For consistency?
> > The function `__throw_bad_array_new_length` is implemented in libstdc++, so it doesn't get defined when using libsupc++ as the ABI library. There is no `__throw_bad_array_new_length function` in libstdc++, but I thought that this might change in the future, so I named the function differently to avoid possible name clash.
> > 
> > But now I noticed that there is a `__cxa_throw_bad_array_new_length` function which is part of the Itanium ABI and is implemented in both libc++abi and libsupc++ (introduced in CXXABI_1.3.8, GCC 4.9). Should I use it instead?
> I meant to say "The function `__throw_bad_alloc `is implemented in libstdc++"
The issue I see with using `__cxa_throw_bad_array_new_length` is the same as with defining `__libcpp_throw_bad_array_new_length` in the dylib -- a program deployed against an OS where the `libc++.dylib` (well, `libc++abi.dylib` really) doesn't ship that symbol would fail to run.


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

https://reviews.llvm.org/D110846



More information about the libcxx-commits mailing list