[flang-commits] [flang] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #69498)

via flang-commits flang-commits at lists.llvm.org
Fri Oct 20 10:24:53 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(
----------------
EricWF wrote:

I think you're forgetting how hot of a path this is. I don't think we want to be doing anything more than we need in the majority of cases.

https://github.com/llvm/llvm-project/pull/69498


More information about the flang-commits mailing list