[Bug libstdc++/69862] New: STL containers not using allocator's definition of pointers

2016-02-17 Thread philippeb8 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69862

Bug ID: 69862
   Summary: STL containers not using allocator's definition of
pointers
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: blocker
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: philippeb8 at gmail dot com
  Target Milestone: ---

This is about STL containers and allocators.  When I look at the code of GCC's
std::list:

  template
void
_List_base<_Tp, _Alloc>::
_M_clear()
{
  typedef _List_node<_Tp>  _Node;
  _Node* __cur = static_cast<_Node*>(_M_impl._M_node._M_next);
  while (__cur != &_M_impl._M_node)
{
  _Node* __tmp = __cur;
  __cur = static_cast<_Node*>(__cur->_M_next);
#if __cplusplus >= 201103L
  _M_get_Node_allocator().destroy(__tmp);
#else
  _M_get_Tp_allocator().destroy(std::__addressof(__tmp->_M_data));
#endif
  _M_put_node(__tmp);
}
}


I think it should make use of the allocator's specific pointer as such:

  template
void
_List_base<_Tp, _Alloc>::
_M_clear()
{
  typedef _List_node<_Tp>  _Node;
  typedef typename _Alloc::rebind<_Node>::other::pointer _NodePtr;

  _NodePtr __cur = static_cast<_NodePtr>(_M_impl._M_node._M_next);
  while (__cur != &_M_impl._M_node)
{
  _NodePtr __tmp = __cur;
  __cur = static_cast<_NodePtr>(__cur->_M_next);
#if __cplusplus >= 201103L
  _M_get_Node_allocator().destroy(__tmp);
#else
  _M_get_Tp_allocator().destroy(std::__addressof(__tmp->_M_data));
#endif
  _M_put_node(__tmp);
}
}

[Bug libstdc++/57272] node-based containers don't use allocator's pointer type internally

2016-02-19 Thread philippeb8 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57272

--- Comment #6 from Phil Bouchard  ---
Also please make sure the pointer arguments are passed by reference and not by
value.  This would ensure we could use our own smart pointers.