diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv index 1215f21985eb9..421ae8c8e3d71 100644 --- a/libcxx/docs/Status/Cxx23Issues.csv +++ b/libcxx/docs/Status/Cxx23Issues.csv @@ -14,7 +14,7 @@ "`LWG2731 `__","Existence of ``lock_guard::mutex_type`` typedef unclear","2020-11 (Virtual)","|Complete|","5","" "`LWG2743 `__","P0083R3 ``node_handle`` private members missing ""exposition only"" comment","2020-11 (Virtual)","|Nothing To Do|","","" "`LWG2820 `__","Clarify ```` macros","2020-11 (Virtual)","|Nothing To Do|","","" -"`LWG3120 `__","Unclear behavior of ``monotonic_buffer_resource::release()``","2020-11 (Virtual)","","","" +"`LWG3120 `__","Unclear behavior of ``monotonic_buffer_resource::release()``","2020-11 (Virtual)","|Complete|","16","" "`LWG3170 `__","``is_always_equal`` added to ``std::allocator`` makes the standard library treat derived types as always equal","2020-11 (Virtual)","|Complete|","18","" "`LWG3036 `__","``polymorphic_allocator::destroy`` is extraneous","2020-11 (Virtual)","|Nothing To Do|","","Reverted by P2875R4" "`LWG3171 `__","LWG2989 breaks ``directory_entry`` stream insertion","2020-11 (Virtual)","|Complete|","14","" diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/release_reset_initial_status.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/release_reset_initial_status.pass.cpp new file mode 100644 index 0000000000000..61406f1d5ffe5 --- /dev/null +++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/release_reset_initial_status.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// REQUIRES: std-at-least-c++17 +// UNSUPPORTED: availability-pmr-missing + +// + +// class monotonic_buffer_resource + +// This test checks the behavior required by LWG3120. + +#include +#include + +#include "count_new.h" +#include "test_macros.h" + +int main(int, char**) { + { + { + // When ctor with a next buffer size. After release(), check whether the next buffer size has been reset after release() + constexpr size_t expect_next_buffer_size = 512; + std::pmr::monotonic_buffer_resource mr{nullptr, expect_next_buffer_size, std::pmr::new_delete_resource()}; + + for (int i = 0; i < 100; ++i) { + (void)mr.allocate(1); + mr.release(); + ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkLastNewSizeGe(expect_next_buffer_size)); + } + } + { + // Check whether the offset of the initial buffer has been reset after release() + constexpr size_t buffer_size = 100; + char buffer[buffer_size]; + std::pmr::monotonic_buffer_resource mr{buffer, buffer_size, std::pmr::null_memory_resource()}; + + mr.release(); + auto expect_mem_start = mr.allocate(60); + mr.release(); + auto ths_mem_start = mr.allocate(60); + assert(expect_mem_start == ths_mem_start); + } + } + return 0; +}