Subject: Re: [Boost-bugs] [Boost C++ Libraries] #13639: monotonic_buffer_resource current_buffer() possibly broken and documentation wrong (was: Documentation of monotonic_buffer_resource looks wrong)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-07-21 15:19:18
#13639: monotonic_buffer_resource current_buffer() possibly broken and
documentation wrong
-------------------------------+---------------------------
Reporter: Markus Dreseler | Owner: Ion Gaztañaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
Version: Boost 1.67.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------------
Changes (by Markus Dreseler):
* severity: Cosmetic => Problem
Comment:
Looking at this again, it looks like current_buffer itself is also broken.
Instead of returning a pointer to the start of the current buffer, it
returns a pointer to where the next allocation should go:
{{{
// clang++ -std=c++1z -lboost_container mbr.cpp
#include <boost/container/pmr/monotonic_buffer_resource.hpp>
#include <boost/container/pmr/polymorphic_allocator.hpp>
#include <iostream>
int main() {
auto buffer =
boost::container::pmr::monotonic_buffer_resource(size_t{100});
auto allocator =
boost::container::pmr::polymorphic_allocator<char>{&buffer};
allocator.allocate(1);
auto start_ptr = buffer.current_buffer();
allocator.allocate(50);
auto end_ptr = buffer.current_buffer();
std::cout << (reinterpret_cast<uintptr_t>(end_ptr) -
reinterpret_cast<uintptr_t>(start_ptr)) << std::endl;
// prints 50, but should be 0
}
}}}
Using clang 6.0 on OSX with boost 1.67.0_1.
-- Ticket URL: <https://svn.boost.org/trac10/ticket/13639#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2018-07-21 15:24:48 UTC