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

S. B. Tam via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 22 19:43:38 PDT 2024


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

`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.

>From 98666e9c0be632ad397640d6b1a05f64b42cbab2 Mon Sep 17 00:00:00 2001
From: "S. B. Tam" <cpplearner at outlook.com>
Date: Thu, 23 May 2024 10:39:22 +0800
Subject: [PATCH] Fix `new_delete_resource.pass.cpp`

---
 .../utility/mem.res/mem.res.global/new_delete_resource.pass.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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));
 }



More information about the libcxx-commits mailing list