[PATCH] PR libstdc++/70940 make pmr::resource_adaptor return aligned memory
Jonathan Wakely
jwakely@redhat.com
Thu Jun 21 16:24:00 GMT 2018
On 21/06/18 16:22 +0100, Jonathan Wakely wrote:
>On 21/06/18 15:00 +0100, Jonathan Wakely wrote:
>> virtual void
>>- do_deallocate(void* __p, size_t __bytes, size_t __alignment)
>>+ do_deallocate(void* __p, size_t __bytes, size_t __alignment) noexcept
>>+ override
>> {
>>- using _Aligned_alloc = std::__alloc_rebind<_Alloc, char>;
>>- size_t __new_size = _S_aligned_size(__bytes,
>>- _S_supported(__alignment) ?
>>- __alignment : _S_max_align);
>>- using _Ptr = typename allocator_traits<_Aligned_alloc>::pointer;
>>- _Aligned_alloc(_M_alloc).deallocate(static_cast<_Ptr>(__p),
>>- __new_size);
>>+ auto __ptr = static_cast<char*>(__p);
>>+ if (__alignment == 1)
>>+ _M_alloc.deallocate(__ptr, __bytes);
>
>Oops, this is missing a return!
>
>Patch incoming ...
Fixed like so, with improved testing too.
Tested x86_64-linux, committed to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 8836 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20180621/3f667ee8/attachment.bin>
More information about the Libstdc++
mailing list