[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #14 from Jonathan Wakely --- P.S. if that failure only appeared recently it would be more useful to mail the libstdc++ list than to add a comment to an old bug that hasn't been touched in years.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #13 from Jonathan Wakely --- Should be fixed at g:01079b6a9236bd467b445fafaff2659840789a85
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #12 from Rimvydas (RJ) --- Missing #include in testsuite gives /z/gg/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc: In function 'bool aligned(void*)': /z/gg/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc:62: error: 'uintptr_t' in namespace 'std' does not name a type compiler exited with status 1 FAIL: experimental/memory_resource/new_delete_resource.cc (test for excess errors) Excess errors: /z/gg/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc:62: error: 'uintptr_t' in namespace 'std' does not name a type UNRESOLVED: experimental/memory_resource/new_delete_resource.cc compilation failed to produce executable
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #11 from Jonathan Wakely --- Author: redi Date: Mon Jul 23 19:40:28 2018 New Revision: 262935 URL: https://gcc.gnu.org/viewcvs?rev=262935=gcc=rev Log: PR libstdc++/70940 optimize pmr::resource_adaptor for allocators using malloc pmr::resource_adaptor can avoid allocating an oversized buffer and doing manual alignment within that buffer when the wrapped allocator is known to always meet the requested alignment. Specifically, if the allocator is known to use malloc or new directly, then we can call the allocator directly for any fundamental alignment. PR libstdc++/70940 * include/experimental/memory_resource (__resource_adaptor_common::_AlignMgr::_M_unadjust): Add assertion. (__resource_adaptor_common::__guaranteed_alignment): New helper to give maximum alignment an allocator guarantees. Specialize for known allocators using new and malloc. (__resource_adaptor_imp::do_allocate): Use __guaranteed_alignment. (__resource_adaptor_imp::do_deallocate): Likewise. * testsuite/experimental/memory_resource/new_delete_resource.cc: Check that new and delete are called with expected sizes. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/experimental/memory_resource trunk/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #10 from Jonathan Wakely --- Author: redi Date: Thu Jun 21 16:24:00 2018 New Revision: 261851 URL: https://gcc.gnu.org/viewcvs?rev=261851=gcc=rev Log: PR libstdc++/70940 make pmr::resource_adaptor return aligned memory PR libstdc++/70940 * include/experimental/memory_resource (__resource_adaptor_imp::do_deallocate): Add missing return. * testsuite/experimental/memory_resource/new_delete_resource.cc: New. * testsuite/experimental/memory_resource/resource_adaptor.cc: Test resource_adaptor with std::allocator, __gnu_cxx::new_allocator and __gnu_cxx::malloc_allocator. Added: trunk/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/experimental/memory_resource trunk/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Jonathan Wakely changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |9.0 --- Comment #9 from Jonathan Wakely --- (In reply to Eric Fiselier from comment #0) > Furthermore it seems that do_allocate returns ill-aligned pointers. It seems > that do_allocate(s, a) returns the pointers from > 'Allocator.allocate(...)' directly even though they have no alignment > guarantees. Fixed by allocating a buffer with additional space. The returned pointer is adjusted to the next alignment boundary, and a token is stored at the end of the allocated buffer to allow removing the adjustment to retrieve the original pointer for deallocation. (In reply to Jonathan Wakely from comment #1) > __null_memory_resource doesn't need to be a class template. Fixed by using a local class. > new_delete_resource() returns something that: > - doesn't have the required is_equal() behaviour. > - only uses new/delete if std::allocator uses __gnu_cxx::new_allocator. Fixed by using new_allocator directly. > And another one from Eric: > Your new_delete_resource() also unnecessarily pads the allocation size > before invoking ::operator new, but that isn't a real bug. I'm not going to fix that for the TS. Without C++17's aligned new we can't rely on calling new/delete directly (at least not for extended alignments). Going via resource_adaptor<__gnu_cxx::new_allocator> gives us the alignment guarantees, at the expense of some extra padding. I considered adding specialization to resource_adaptor so that when using new_allocator (or std::allocator when that uses new_allocator) it would avoid doing the padding for fundamental alignments. Maybe at a later date. For C++17's std::pmr::new_delete_resource() we can just use aligned new directly and don't need to wrap new_allocator and over-allocate (and if the user uses -fno-aligned-new they don't get a new_delete_resource). Closing as fixed on trunk.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #8 from Jonathan Wakely --- Author: redi Date: Thu Jun 21 14:01:11 2018 New Revision: 261849 URL: https://gcc.gnu.org/viewcvs?rev=261849=gcc=rev Log: PR libstdc++/70940 make pmr::resource_adaptor return aligned memory PR libstdc++/70940 * include/experimental/memory_resource (__resource_adaptor_common): New base class. (__resource_adaptor_common::_AlignMgr): Helper for obtaining aligned pointer from unaligned, and vice versa. (__resource_adaptor_imp::do_allocate): Use _AlignMgr to adjust allocated pointer to meet alignment request. (__resource_adaptor_imp::do_deallocate): Use _AlignMgr to retrieve original pointer for deallocation. (__resource_adaptor_imp::do_is_equal): Reformat. (__resource_adaptor_imp::_S_aligned_size): Remove. (__resource_adaptor_imp::_S_supported): Remove. (new_delete_resource): Use __gnu_cxx::new_allocator. * testsuite/experimental/memory_resource/resource_adaptor.cc: Test extended alignments and use debug_allocator to check for matching allocate/deallocate pairs. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/experimental/memory_resource trunk/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Jonathan Wakely changed: What|Removed |Added Target Milestone|7.4 |---
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Richard Biener changed: What|Removed |Added Target Milestone|7.3 |7.4 --- Comment #7 from Richard Biener --- GCC 7.3 is being released, adjusting target milestone.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Richard Biener changed: What|Removed |Added Target Milestone|7.2 |7.3
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Richard Biener changed: What|Removed |Added Target Milestone|7.2 7.2 |7.3 7.3 --- Comment #7 from Richard Biener --- GCC 7.2 is being released, adjusting target milestone. --- Comment #8 from Richard Biener --- GCC 7.2 is being released, adjusting target milestone.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Richard Biener changed: What|Removed |Added Target Milestone|7.2 7.2 |7.3 7.3 --- Comment #7 from Richard Biener --- GCC 7.2 is being released, adjusting target milestone. --- Comment #8 from Richard Biener --- GCC 7.2 is being released, adjusting target milestone.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Jakub Jelinek changed: What|Removed |Added Target Milestone|7.0 |7.2 --- Comment #6 from Jakub Jelinek --- GCC 7.1 has been released.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Jonathan Wakely changed: What|Removed |Added Target Milestone|6.2 |7.0 --- Comment #5 from Jonathan Wakely --- The worst problems are fixed on the gcc-6-branch for 6.2 I'll keep this open for the other issues but only plan to fix them on trunk.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #4 from Jonathan Wakely --- Author: redi Date: Sat Aug 6 12:20:31 2016 New Revision: 239199 URL: https://gcc.gnu.org/viewcvs?rev=239199=gcc=rev Log: libstdc++/70940 Start fixing polymorphic memory resources Backport from mainline 2016-05-04 Jonathan WakelyPR libstdc++/70940 * include/experimental/memory_resource (__resource_adaptor_imp::do_allocate): Do not default-construct rebound allocator. (__resource_adaptor_imp::do_deallocate): Likewise. Use allocator_traits to get pointer type. (__null_memory_resource::do_allocate): Remove unused parameters. (__null_memory_resource::do_deallocate): Likewise. (__null_memory_resource::do_is_equal): Likewise. Add return statement. * testsuite/experimental/type_erased_allocator/1.cc: Combine with ... * testsuite/experimental/type_erased_allocator/1_neg.cc: This, and move to ... * testsuite/experimental/memory_resource/1.cc: Here. * testsuite/experimental/memory_resource/null_memory_resource.cc: New. * testsuite/experimental/memory_resource/resource_adaptor.cc: New. Added: branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/memory_resource/ branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/memory_resource/1.cc - copied, changed from r239198, branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/type_erased_allocator/1.cc branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc - copied, changed from r239198, branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/type_erased_allocator/1_neg.cc branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc Removed: branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/type_erased_allocator/1.cc branches/gcc-6-branch/libstdc++-v3/testsuite/experimental/type_erased_allocator/1_neg.cc Modified: branches/gcc-6-branch/libstdc++-v3/ChangeLog branches/gcc-6-branch/libstdc++-v3/include/experimental/memory_resource
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Jonathan Wakely changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Target Milestone|--- |6.2 --- Comment #3 from Jonathan Wakely --- (In reply to Eric Fiselier from comment #0) > resource_adapter incorrectly requires that the Allocator provide: > * A pointer typedef. > * A default constructor. Those errors are fixed on trunk now. (In reply to Jonathan Wakely from comment #1) > Also: > > __null_memory_resource::do_is_equal() is missing a return statement, so > returns garbage off the stack. So is this. The rest isn't yet.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #2 from Jonathan Wakely --- Author: redi Date: Wed May 4 12:08:45 2016 New Revision: 235868 URL: https://gcc.gnu.org/viewcvs?rev=235868=gcc=rev Log: libstdc++/70940 Start fixing polymorphic memory resources PR libstdc++/70940 * include/experimental/memory_resource (__resource_adaptor_imp::do_allocate): Do not default-construct rebound allocator. (__resource_adaptor_imp::do_deallocate): Likewise. Use allocator_traits to get pointer type. (__null_memory_resource::do_allocate): Remove unused parameters. (__null_memory_resource::do_deallocate): Likewise. (__null_memory_resource::do_is_equal): Likewise. Add return statement. * testsuite/experimental/type_erased_allocator/1.cc: Combine with ... * testsuite/experimental/type_erased_allocator/1_neg.cc: This, and move to ... * testsuite/experimental/memory_resource/1.cc: Here. * testsuite/experimental/memory_resource/null_memory_resource.cc: New. * testsuite/experimental/memory_resource/resource_adaptor.cc: New. Added: trunk/libstdc++-v3/testsuite/experimental/memory_resource/ trunk/libstdc++-v3/testsuite/experimental/memory_resource/1.cc - copied, changed from r235859, trunk/libstdc++-v3/testsuite/experimental/type_erased_allocator/1.cc trunk/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc - copied, changed from r235859, trunk/libstdc++-v3/testsuite/experimental/type_erased_allocator/1_neg.cc trunk/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc Removed: trunk/libstdc++-v3/testsuite/experimental/type_erased_allocator/1.cc trunk/libstdc++-v3/testsuite/experimental/type_erased_allocator/1_neg.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/experimental/memory_resource
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 --- Comment #1 from Jonathan Wakely --- Also: __null_memory_resource::do_is_equal() is missing a return statement, so returns garbage off the stack. __null_memory_resource doesn't need to be a class template. new_delete_resource() returns something that: - doesn't have the required is_equal() behaviour. - only uses new/delete if std::allocator uses __gnu_cxx::new_allocator. And another one from Eric: Your new_delete_resource() also unnecessarily pads the allocation size before invoking ::operator new, but that isn't a real bug.
[Bug libstdc++/70940] pmr::resource_adaptor requires optional allocator requirements and incorrectly aligns returned pointers.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2016-05-04 Ever confirmed|0 |1