Skip to content

Commit f30ce1a

Browse files
committed
[libc++] Update the status for lwg-3120
Current implementation already have struct __initial_descriptor which saves the initial state. When release() called, we will reset ptr __initial_descriptor.__cur_, next buffer size never changed. This patch update the lwg 3120 issue latest status and add test.
1 parent de12bf5 commit f30ce1a

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

libcxx/docs/Status/Cxx23Issues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"`LWG2731 <https://wg21.link/LWG2731>`__","Existence of ``lock_guard<MutexTypes...>::mutex_type`` typedef unclear","2020-11 (Virtual)","|Complete|","5",""
1515
"`LWG2743 <https://wg21.link/LWG2743>`__","P0083R3 ``node_handle`` private members missing ""exposition only"" comment","2020-11 (Virtual)","|Nothing To Do|","",""
1616
"`LWG2820 <https://wg21.link/LWG2820>`__","Clarify ``<cstdint>`` macros","2020-11 (Virtual)","|Nothing To Do|","",""
17-
"`LWG3120 <https://wg21.link/LWG3120>`__","Unclear behavior of ``monotonic_buffer_resource::release()``","2020-11 (Virtual)","","",""
17+
"`LWG3120 <https://wg21.link/LWG3120>`__","Unclear behavior of ``monotonic_buffer_resource::release()``","2020-11 (Virtual)","|Complete|","16",""
1818
"`LWG3170 <https://wg21.link/LWG3170>`__","``is_always_equal`` added to ``std::allocator`` makes the standard library treat derived types as always equal","2020-11 (Virtual)","|Complete|","18",""
1919
"`LWG3036 <https://wg21.link/LWG3036>`__","``polymorphic_allocator::destroy`` is extraneous","2020-11 (Virtual)","|Nothing To Do|","","Reverted by P2875R4"
2020
"`LWG3171 <https://wg21.link/LWG3171>`__","LWG2989 breaks ``directory_entry`` stream insertion","2020-11 (Virtual)","|Complete|","14",""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
// UNSUPPORTED: c++03, c++11, c++14
11+
// UNSUPPORTED: availability-pmr-missing
12+
13+
// <memory_resource>
14+
15+
// class monotonic_buffer_resource
16+
17+
#include <memory_resource>
18+
#include <cassert>
19+
#include <tuple> // std::ignore
20+
21+
#include "count_new.h"
22+
#include "test_macros.h"
23+
24+
int main(int, char**) {
25+
{
26+
// https://cplusplus.github.io/LWG/issue3120
27+
{
28+
// when init given a next buffer size, after release(), reset/not change next buffer size from initial state
29+
constexpr auto expect_next_buffer_size{512ULL};
30+
std::pmr::monotonic_buffer_resource mr{nullptr, expect_next_buffer_size, std::pmr::new_delete_resource()};
31+
32+
for (auto i{0}; i < 100; ++i) {
33+
std::ignore = mr.allocate(1);
34+
mr.release();
35+
ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkLastNewSizeGe(expect_next_buffer_size));
36+
}
37+
}
38+
{
39+
// Given
40+
// when init given a buffer, after release(), initial ptr will reset to it's initial state
41+
constexpr auto buffer_size{512ULL};
42+
char buffer[buffer_size];
43+
std::pmr::monotonic_buffer_resource mr{buffer, buffer_size, std::pmr::null_memory_resource()};
44+
45+
auto expect_mem_start = mr.allocate(1);
46+
for (auto i{0}; i < 100; ++i) {
47+
mr.release();
48+
auto ths_mem_start = mr.allocate(1);
49+
assert(expect_mem_start == ths_mem_start);
50+
}
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)