[Bug libstdc++/103162] overconstrained std::pmr::memory_resource allocate/deallocate methods

florin.iucha at amd dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 10 16:08:33 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103162

--- Comment #10 from Florin Iucha <florin.iucha at amd dot com> ---
(In reply to Jonathan Wakely from comment #8)
> > There are uses for the memory_resources pattern, outside of its current
> > application in the standard library - for example allocating ranges in a
> > file, or in a shared memory segment. 0 is valid allocation, although
> > obviously not directly dereferenceable.
> 
> Well then it's not a valid use of pmr::memory_resource. It needs to return a
> pointer to dereferenceable memory (after casting it from void* to something
> else of course).
>
... 
>
> If you're abusing the pmr::memory_resource interface to return a uintptr_t
> disguised a a void*, well that's abusing the API and not intended to be
> supported (according to the author of the proposal that added it to C++).

Thank you for taking the time to consider this - I will create the "abstract
integer range" allocator and use that for the other use cases.

It might be good though to update the documentation - perhaps even on
cppreference if you have access - to explicitly indicate these constraints as
following from the design intent.


More information about the Gcc-bugs mailing list