[libc-commits] [libc] 73799b4 - [libc] Added missing operator delete generated by gcc/clang (#67457)
via libc-commits
libc-commits at lists.llvm.org
Wed Jul 17 08:20:21 PDT 2024
Author: Mikhail R. Gadelha
Date: 2024-07-17T12:20:15-03:00
New Revision: 73799b46072c2241ae32c87f478a7e2a30c0e1a3
URL: https://github.com/llvm/llvm-project/commit/73799b46072c2241ae32c87f478a7e2a30c0e1a3
DIFF: https://github.com/llvm/llvm-project/commit/73799b46072c2241ae32c87f478a7e2a30c0e1a3.diff
LOG: [libc] Added missing operator delete generated by gcc/clang (#67457)
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)).
Added:
Modified:
libc/test/UnitTest/HermeticTestUtils.cpp
Removed:
################################################################################
diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp
index 85e5cf02ff613..47f813b0b7a4e 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -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); }
@@ -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();
+}
More information about the libc-commits
mailing list