[PATCH] PR72792 PR72793 relax requirements on rebind members
Jonathan Wakely
jwakely@redhat.com
Fri Jan 20 12:04:00 GMT 2017
On 20/01/17 02:37 +0000, Jonathan Wakely wrote:
>I misread the specifications for pointer_traits::rebind and
>allocator_traits::rebind_alloc and was requiring them to be valid for
>any specialization of the class templates. In fact they're only needed
>if instantiated. This fixes the problem.
>
> PR libstdc++/72792
> PR libstdc++/72793
> * include/bits/alloc_traits.h (__allocator_traits_base::__rebind):
> Replace with class template using void_t.
> (__alloc_rebind): Define in terms of
> __allocator_traits_base::__rebind.
> (allocator_traits): Remove unconditional static_assert for
> rebind_alloc.
> * include/bits/ptr_traits.h (__replace_first_arg): Remove type member.
> (pointer_traits::__rebind): Replace with class template using void_t.
> (pointer_traits::rebind): Define in terms of __rebind.
> (pointer_traits): Remove unconditional static_assert for rebind.
> * testsuite/20_util/allocator_traits/members/rebind_alloc.cc: New test.
> * testsuite/20_util/pointer_traits/rebind.cc: New test.
>
>Tested powerpc64le-linux, committed to trunk.
That patch prevented pointer_traits::rebind being instantiated
automatically when pointer_traits is instantiated. We need a further
fix to prevent allocator_traits from doing invalid instantiations of
pointer_traits::rebind when detecting the const_pointer, void_pointer
and const_void_pointer types. Currently we rebind the pointer type too
early, even when it isn't needed, and that can fail.
With this patch we delay trying to use pointer_traits::rebind until we
know it's really needed. I've also done something similar for
difference_type and size_type, although I think that's maybe overkill
because pointer_traits::difference_type is always supposed to be
valid, and because the Allocator requirements say difference_type must
be a signed integer type, so using make_unsigned on it must also be
valid always.
Tested powerpc64le-linux, committed to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 8653 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170120/12417bd5/attachment.bin>
More information about the Libstdc++
mailing list