[clang-tools-extra] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #69498)
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 20 10:53:00 PDT 2023
================
@@ -38,39 +44,53 @@ static void* operator_new_impl(std::size_t size) noexcept {
_LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC {
void* p = operator_new_impl(size);
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
if (p == nullptr)
- throw std::bad_alloc();
-# endif
+ __throw_bad_alloc_shim();
return p;
}
_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
+# ifdef _LIBCPP_HAS_NO_EXCEPTIONS
+ _LIBCPP_ASSERT_SHIM(
----------------
ldionne wrote:
We could make this part of the `DEBUG_LITE` mode then, I guess.
https://github.com/llvm/llvm-project/pull/69498
More information about the cfe-commits
mailing list