This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR libstdc++/70940 make pmr::resource_adaptor return aligned memory


On 22/06/18 13:42 +0100, Jonathan Wakely wrote:
On 22/06/18 14:34 +0200, Rainer Orth wrote:
Hi Jonathan,

	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.

Tested x86_64-linux, committed to trunk. This is more experimental TS
material, so I'll probably backport it.

this patch has cause a couple of FAILures on 32-bit targets/multilibs.
I'm seeing it on i386-pc-solaris2.11 and sparc-sun-solaris2.11, with
gcc-testresults postings to the same effect for
i586-unknown-freebsd10.4, i686-pc-linux-gnu, s390x-ibm-linux-gnu,
x86_64-pc-linux-gnu:

+FAIL: experimental/memory_resource/1.cc (test for excess errors)
+FAIL: experimental/memory_resource/70966.cc (test for excess errors)
+FAIL: experimental/memory_resource/null_memory_resource.cc (test for excess errors)
+FAIL: experimental/memory_resource/resource_adaptor.cc (test for excess errors)
+XPASS: experimental/memory_resource/resource_adaptor.cc execution test
+FAIL: experimental/type_erased_allocator/2.cc (test for excess errors)

FAIL: experimental/type_erased_allocator/2.cc (test for excess errors)
Excess errors:
/var/gcc/regression/trunk/11.4-gcc/build/i386-pc-solaris2.11/libstdc++-v3/include/experimental/memory_resource:329: warning: left shift count >= width of type [-Wshift-count-overflow]

David just created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86280

This should fix it. I'll commit it later, or if you want to test and
commit it please go ahead.

--- a/libstdc++-v3/include/experimental/memory_resource
+++ b/libstdc++-v3/include/experimental/memory_resource
@@ -326,7 +326,7 @@ namespace pmr {
        return 1;
      if (_M_align <= (1ul << (sizeof(short) * __CHAR_BIT__)))
        return sizeof(short);
-       if (_M_align <= (1ul << (sizeof(int) * __CHAR_BIT__)))
+       if (_M_align <= (1ull << (sizeof(int) * __CHAR_BIT__)))
        return sizeof(int);
      return sizeof(char*);
     }


Committed to trunk.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]