[libcxx-commits] [libcxx] [libc++][test] Fix `new_delete_resource.pass.cpp` by passing correct size to `deallocate` (PR #93126)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 22 19:44:06 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: S. B. Tam (cpplearner)

<details>
<summary>Changes</summary>

`memory_resource` requires that the value passed to `deallocate` matches the argument of `allocate` ([\[mem.res.private\]/4](http://eel.is/c++draft/mem.res.private#<!-- -->4)). Apparently this matters for ASAN.

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


1 Files Affected:

- (modified) libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp (+1-1) 


``````````diff
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp
index 68a82f6ce90b3..7b3107029d4d8 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp
@@ -76,7 +76,7 @@ void test_allocate_deallocate() {
   ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkOutstandingNewEq(1));
   ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkLastNewSizeEq(50));
 
-  r1.deallocate(ret, 1);
+  r1.deallocate(ret, 50);
   assert(globalMemCounter.checkOutstandingNewEq(0));
   ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkDeleteCalledEq(1));
 }

``````````

</details>


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


More information about the libcxx-commits mailing list