Skip to content

Commit

Permalink
[libc] Added missing operator delete generated by gcc/clang (#67457)
Browse files Browse the repository at this point in the history
This patch adds two operators delete that are being generated by clang 15 on rv32 (operator delete(void *mem, std::align_val_t)) and by gcc 13 on intel 64 (operator delete(void *mem, unsigned long)).
  • Loading branch information
mikhailramalho authored Jul 17, 2024
1 parent e9fdc68 commit 73799b4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion libc/test/UnitTest/HermeticTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ unsigned long __getauxval(unsigned long id) {

} // extern "C"

void *operator new(unsigned long size, void *ptr) { return ptr; }
void *operator new(size_t size, void *ptr) { return ptr; }

void *operator new(size_t size) { return malloc(size); }

Expand All @@ -137,3 +137,16 @@ void operator delete(void *) {
}

void operator delete(void *ptr, size_t size) { __builtin_trap(); }

// Defining members in the std namespace is not preferred. But, we do it here
// so that we can use it to define the operator new which takes std::align_val_t
// argument.
namespace std {
enum class align_val_t : size_t {};
} // namespace std

void operator delete(void *mem, std::align_val_t) noexcept { __builtin_trap(); }

void operator delete(void *mem, unsigned int, std::align_val_t) noexcept {
__builtin_trap();
}

0 comments on commit 73799b4

Please sign in to comment.