User account creation filtered due to spam.

Bug 15775 - Allocator::pointer consistently ignored
Summary: Allocator::pointer consistently ignored
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-02 12:22 UTC by Carlo Wood
Modified: 2004-06-11 18:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-06-09 09:45:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlo Wood 2004-06-02 12:22:44 UTC
Many (if not all) STL containers use typedefs like:

      typedef value_type*                        pointer;
      typedef const value_type*                  const_pointer;
      typedef value_type&                        reference;
      typedef const value_type&                  const_reference;

However, according to the standard it should be Allocator::pointer etc.
For example, 23.2.1 Template class deque [lib.deque] says

namespace std {
  template <class T, class Allocator = allocator<T> >
  class deque {
  public:
    // types:
    typedef typename Allocator::reference         reference;
    typedef typename Allocator::const_reference   const_reference;
                                                                   // See 23.1
    typedef implementation defined                iterator;
                                                  const_iterator; // See 23.1
    typedef implementation defined
                                                                   // See 23.1
    typedef implementation defined                size_type;
                                                  difference_type; // See 23.1
    typedef implementation defined
    typedef T                                     value_type;
    typedef Allocator                             allocator_type;
    typedef typename Allocator::pointer           pointer;
    typedef typename Allocator::const_pointer     const_pointer;
    typedef std::reverse_iterator<iterator>       reverse_iterator;
    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;


and since Allocator is a user specified class, it cannot be correct
to replace these 'typename Allocator::pointer' with 'value_type*'.
Comment 1 Paolo Carlini 2004-06-09 09:45:33 UTC
Confirmed: for some reason, when fixing libstdc++/13462 we didn't notice that
the problem was more general.
Comment 2 Paolo Carlini 2004-06-09 10:10:47 UTC
Notice, however, that at variance with the specific cases fixed for 13462, the
remaining containers are essentially ok (i.e., the change is only cosmetic) due
to the Standard requirements for allocators (Table 32): allocator<T>::pointer
is required to be T*, for instance.
Comment 3 CVS Commits 2004-06-09 21:37:54 UTC
Subject: Bug 15775

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2004-06-09 21:37:47

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: stl_deque.h stl_list.h stl_map.h 
	                           stl_multimap.h stl_vector.h 

Log message:
	2004-06-09  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/15775
	* include/bits/stl_deque.h: Consistently with stl_set.h, define
	pointer as allocator's pointer, likewise for reference,
	const_pointer, and const_reference.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_vector.h: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2507&r2=1.2508
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_deque.h.diff?cvsroot=gcc&r1=1.49&r2=1.50
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_list.h.diff?cvsroot=gcc&r1=1.40&r2=1.41
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_map.h.diff?cvsroot=gcc&r1=1.24&r2=1.25
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_multimap.h.diff?cvsroot=gcc&r1=1.23&r2=1.24
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_vector.h.diff?cvsroot=gcc&r1=1.48&r2=1.49

Comment 4 Benjamin Kosnik 2004-06-09 22:05:19 UTC
paolo can you put this on gcc-3_4-branch too, at some date before 3.4.1?

thanks,
benjamin
Comment 5 CVS Commits 2004-06-11 18:45:06 UTC
Subject: Bug 15775

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	paolo@gcc.gnu.org	2004-06-11 18:44:58

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/testsuite: testsuite_performance.h 
	libstdc++-v3/include/bits: stl_deque.h stl_list.h stl_map.h 
	                           stl_multimap.h stl_vector.h 

Log message:
	2004-06-11  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/15775
	* include/bits/stl_deque.h: Consistently with stl_set.h, define
	pointer as allocator's pointer, likewise for reference,
	const_pointer, and const_reference.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	
	2004-06-11  Dhruv Matani  <dhruvbird@gmx.net>
	Paolo Carlini  <pcarlini@suse.de>
	
	* testsuite/testsuite_performance.h
	(resource_counter::allocated_memory): Make it return the right
	number of bytes requested by the allocators/application. This is
	the sbrk+mmaped memory.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2224.2.124&r2=1.2224.2.125
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/testsuite_performance.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.11.4.1&r2=1.11.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_deque.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.44.4.3&r2=1.44.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_list.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.34.4.3&r2=1.34.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_map.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.19.6.2&r2=1.19.6.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_multimap.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.19.6.2&r2=1.19.6.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/stl_vector.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.43.4.3&r2=1.43.4.4

Comment 6 Paolo Carlini 2004-06-11 18:46:22 UTC
Fixed for 3.4.1.