[Bug libstdc++/55409] std::list not properly wrapping access to custom allocator through allocator_traits

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jun 17 21:58:00 GMT 2015


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

--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Krauss from comment #13)
> 1. Line 304: rebind isn’t an official member of allocator_traits. Prefer
> rebind_alloc.

That isn't allocator_traits, it's __gnu_cxx::__alloc_traits, which is a
compatibility layer that works the same in C++03 and C++11. It has rebind, not
rebind_alloc, see <ext/alloc_traits.h>

> 2. _M_put_node is assuming no fancy pointers: its parameter is a
> _Node_alloc_traits::pointer but its argument is a _Node*. I think the intent
> with fancy pointers is that they get stored in nodes,

I agree it's desirable, but it's not really clear that it's required, see
http://cplusplus.github.io/LWG/lwg-active.html#2261

> but doing so would
> change the ABI for fancy pointers that implicitly convert to raw. Perhaps
> that’s acceptable, with these sweeping changes?

These changes shouldn't affect the ABI. 

I have patches coming some time for fancy pointers in all containers, for
PR57272, which also don't affect the ABI. My plan is to use the existing node
types for allocators without fancy pointers, but use a new family of types
(_List_ptr_node, _List_ptr_iterator etc.) that use fancy pointers. That will
preserve ABI compatibility for non-fancy pointers, but also fully support fancy
pointers. But it's a lot of work, due to the backward-compatibility
requirements.

> 3. Line 554: should call _Node_alloc_traits::construct. (This breaks
> allocators which need a rebind to do construction, but so does the C++11
> standard. To be both backward- and forward-compatible would require
> rebinding, converting, constructing via traits, converting back, and
> assigning. According to my reading, anyway.) For what it’s worth, the
> revision already uses _Node_alloc_traits::destroy, although that’s
> customized less in practice.

Line 504 is only compiled in C++98 mode, where allocators are required to
provide a construct member.


More information about the Gcc-bugs mailing list