Skip to content

Commit 096b901

Browse files
sicherhaChristoph Erhardt
authored andcommitted
Fix compatibility with GNU libstdc++ < 9
So far, mimalloc does not override the `nothrow` variants of the `delete` operator because it assumes that their implementation in the C++ standard library redirects to the default `delete` operators. This is not the case for GNU libstdc++ < 9, where `std::free()` is called directly. This issue might be the cause for the crashes reported in #261. Upstream bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68210 This commit ensures that the `nothrow` `delete` operators are properly overridden by mimalloc.
1 parent 817569d commit 096b901

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/mimalloc-new-delete.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ terms of the MIT license. A copy of the license can be found in the file
2525
void operator delete(void* p) noexcept { mi_free(p); };
2626
void operator delete[](void* p) noexcept { mi_free(p); };
2727

28+
void operator delete (void* p, const std::nothrow_t&) noexcept { mi_free(p); }
29+
void operator delete[](void* p, const std::nothrow_t&) noexcept { mi_free(p); }
30+
2831
void* operator new(std::size_t n) noexcept(false) { return mi_new(n); }
2932
void* operator new[](std::size_t n) noexcept(false) { return mi_new(n); }
3033

0 commit comments

Comments
 (0)