This is the mail archive of the 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]

[libstdc++] Problems with deques (patch included)

When I use the deque class with a custom allocator, I get "member
initializers will be reordered" warnings on the main line.

Applying the appended patch fixes the problem.

Hope this helps,

Peter Schmid

source file td.C

namespace ns {
  template <class T>
  class my_allocator {
    typedef T* pointer;
    typedef std::size_t size_type;

    template <class U>
    struct rebind
      typedef my_allocator<U> other;

    my_allocator() throw() {}
    my_allocator(const my_allocator&) throw() {}
    template <class U>
    my_allocator (const my_allocator<U>&) throw() {}
    ~my_allocator() throw() {}
    pointer allocate (size_type , const void* = 0) { return 0; }
     void deallocate (pointer , size_type ) {}

std::deque<int, ns::my_allocator<int> > d;

g++ -v -c -W -Wall td.C
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-languages=c,c++,f77,objc,treelang
Thread model: posix
gcc version 3.2 20020707 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/cc1plus -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE td.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase td.C -W -Wall -version -o /tmp/cc7rS88c.s
GNU C++ version 3.2 20020707 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.2 20020707 (experimental).
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
/usr/local/include/c++/3.2/bits/stl_deque.h: In constructor `
   std::_Deque_alloc_base<_Tp, _Alloc, __is_static>::_Deque_alloc_base(typename
   std::_Alloc_traits<_Tp, _Allocator>::allocator_type&) [with _Tp = int,
   _Alloc = ns::my_allocator<int>, bool __is_static = false]':
/usr/local/include/c++/3.2/bits/stl_deque.h:460:   instantiated from `std::_Deque_base<_Tp, _Alloc>::_Deque_base(typename std::_Deque_alloc_base<_Tp, _Alloc, std::_Alloc_traits<_Tp, _Allocator>::_S_instanceless>::allocator_type&, unsigned int) [with _Tp = int, _Alloc = ns::my_allocator<int>]'
/usr/local/include/c++/3.2/bits/stl_deque.h:690:   instantiated from `std::deque<_Tp, _Alloc>::deque(typename std::_Deque_base<_Tp, _Alloc>::allocator_type&) [with _Tp = int, _Alloc = ns::my_allocator<int>]'
td.C:26:   instantiated from here
/usr/local/include/c++/3.2/bits/stl_deque.h:391: warning: member initializers
   for `ns::my_allocator<int*> std::_Deque_alloc_base<int,
   ns::my_allocator<int>, false>::_M_map_allocator'
/usr/local/include/c++/3.2/bits/stl_deque.h:388: warning:   and `
   int**std::_Deque_alloc_base<int, ns::my_allocator<int>, false>::_M_map'
/usr/local/include/c++/3.2/bits/stl_deque.h:362: warning:   will be re-ordered
   to match declaration order
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o td.o /tmp/cc7rS88c.s
GNU assembler version 020627 (i686-pc-linux-gnu) using BFD version 020627 20020627

2002-07-08  Peter Schmid  <>

	* include/bits/stl_deque.h: Change order of member
	variable declarations to avoid compiler warnings

*** libstdc++-v3/include/bits/stl_deque.h.orig	Mon Jul  8 01:55:06 2002
--- libstdc++-v3/include/bits/stl_deque.h	Mon Jul  8 01:55:10 2002
*************** protected:
*** 385,394 ****
    _M_deallocate_map(_Tp** __p, size_t __n)
      { _M_map_allocator.deallocate(__p, __n); }

-   _Tp**                _M_map;
-   size_t               _M_map_size;
    allocator_type       _M_node_allocator;
    _Map_allocator_type  _M_map_allocator;

  /// @if maint Specialization for instanceless allocators.  @endif
--- 385,394 ----
    _M_deallocate_map(_Tp** __p, size_t __n)
      { _M_map_allocator.deallocate(__p, __n); }

    allocator_type       _M_node_allocator;
    _Map_allocator_type  _M_map_allocator;
+   _Tp**                _M_map;
+   size_t               _M_map_size;

  /// @if maint Specialization for instanceless allocators.  @endif

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