[libc-commits] [libc] [libc] Added missing operator delete generated by gcc/clang (PR #67457)

via libc-commits libc-commits at lists.llvm.org
Tue Sep 26 10:05:21 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

<details>
<summary>Changes</summary>

This patch adds two operator delete functions 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)).

---
Full diff: https://github.com/llvm/llvm-project/pull/67457.diff


1 Files Affected:

- (modified) libc/test/UnitTest/HermeticTestUtils.cpp (+19) 


``````````diff
diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp b/libc/test/UnitTest/HermeticTestUtils.cpp
index 73d54b9eeb5ecc9..d4628091f30fac2 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -109,3 +109,22 @@ void operator delete(void *) {
   // we just trap here to catch any such accidental usages.
   __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 {
+  // The libc runtime should not use the global delete operator. Hence,
+  // we just trap here to catch any such accidental usages.
+  __builtin_trap();
+}
+
+void operator delete(void *mem, unsigned long) noexcept {
+  // The libc runtime should not use the global delete operator. Hence,
+  // we just trap here to catch any such accidental usages.
+  __builtin_trap();
+}

``````````

</details>


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


More information about the libc-commits mailing list