[v3] libstdc++/27199

Marc Glisse marc.glisse@normalesup.org
Fri Apr 21 17:54:00 GMT 2006


Hello,

(it is the first time I propose a patch so please tell me if I am doing 
anything wrong)

The issue here is that several c++ headers use size_t and ptrdiff_t in 
namespace __gnu_cxx without specifying std::.

In bits/ and debug/, there was only a single error, so I just added std::.

In ext/ there are way more issues, and since there are already headers 
there that do "using std::size_t;" in namespace __gnu_cxx, I thought it 
was easier to just add the same to the headers were it was missing. It 
might be more consistent to add the "using" line to bits/char_traits.h and 
debug/hash_multimap.h (or even to cstddef), I don't know.

Solving this will not fix anything immediately but may help for #6257.

I tried the testsuite on i686-pc-linux-gnu and it seems to me that it 
changed nothing (although I am not used to this).

-- 
Marc Glisse
-------------- next part --------------
Index: ext/pool_allocator.h
===================================================================
--- ext/pool_allocator.h	(r?vision 113135)
+++ ext/pool_allocator.h	(copie de travail)
@@ -56,6 +56,9 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+  using std::size_t;
+  using std::ptrdiff_t;
+
   /**
    *  @brief  Base class for __pool_alloc.
    *
Index: ext/bitmap_allocator.h
===================================================================
--- ext/bitmap_allocator.h	(r?vision 113135)
+++ ext/bitmap_allocator.h	(copie de travail)
@@ -71,6 +71,9 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+  using std::size_t;
+  using std::ptrdiff_t;
+
 #if defined __GTHREADS
   namespace
   {
@@ -238,8 +241,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 	typedef _Tp* pointer;
 	typedef _Tp& reference;
 	typedef const _Tp& const_reference;
-	typedef std::size_t size_type;
-	typedef std::ptrdiff_t difference_type;
+	typedef size_t size_type;
+	typedef ptrdiff_t difference_type;
 	typedef pointer iterator;
 
       private:
@@ -396,7 +399,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       struct __mv_iter_traits<_Tp*>
       {
 	typedef _Tp value_type;
-	typedef std::ptrdiff_t difference_type;
+	typedef ptrdiff_t difference_type;
       };
 
     enum 
@@ -865,8 +868,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
     class bitmap_allocator : private free_list
     {
     public:
-      typedef std::size_t    size_type;
-      typedef std::ptrdiff_t difference_type;
+      typedef size_t    size_type;
+      typedef ptrdiff_t difference_type;
       typedef _Tp*        pointer;
       typedef const _Tp*  const_pointer;
       typedef _Tp&        reference;
Index: ext/new_allocator.h
===================================================================
--- ext/new_allocator.h	(r?vision 113135)
+++ ext/new_allocator.h	(copie de travail)
@@ -39,6 +39,9 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+  using std::size_t;
+  using std::ptrdiff_t;
+
   /**
    *  @brief  An allocator that uses global new, as per [20.4].
    *
Index: ext/malloc_allocator.h
===================================================================
--- ext/malloc_allocator.h	(r?vision 113135)
+++ ext/malloc_allocator.h	(copie de travail)
@@ -40,6 +40,9 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+  using std::size_t;
+  using std::ptrdiff_t;
+
   /**
    *  @brief  An allocator that uses malloc.
    *
Index: ext/functional
===================================================================
--- ext/functional	(r?vision 113135)
+++ ext/functional	(copie de travail)
@@ -67,6 +67,7 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+  using std::size_t;
   using std::unary_function;
   using std::binary_function;
   using std::mem_fun1_t;
Index: ext/array_allocator.h
===================================================================
--- ext/array_allocator.h	(r?vision 113135)
+++ ext/array_allocator.h	(copie de travail)
@@ -41,6 +41,9 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+ using std::size_t;
+ using std::ptrdiff_t;
+
   /// @brief  Base class.
  template<typename _Tp>
     class array_allocator_base
Index: ext/mt_allocator.h
===================================================================
--- ext/mt_allocator.h	(r?vision 113135)
+++ ext/mt_allocator.h	(copie de travail)
@@ -42,6 +42,9 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+  using std::size_t;
+  using std::ptrdiff_t;
+
   typedef void (*__destroy_handler)(void*);
 
   /// @brief  Base class for pool object.
Index: ext/debug_allocator.h
===================================================================
--- ext/debug_allocator.h	(r?vision 113135)
+++ ext/debug_allocator.h	(copie de travail)
@@ -52,6 +52,8 @@
 
 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
 
+  using std::size_t;
+
   /**
    *  @brief  A meta-allocator with debugging bits, as per [20.4].
    *
Index: bits/char_traits.h
===================================================================
--- bits/char_traits.h	(r?vision 113135)
+++ bits/char_traits.h	(copie de travail)
@@ -148,7 +148,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
     char_traits<_CharT>::
     compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
     {
-      for (size_t __i = 0; __i < __n; ++__i)
+      for (std::size_t __i = 0; __i < __n; ++__i)
 	if (lt(__s1[__i], __s2[__i]))
 	  return -1;
 	else if (lt(__s2[__i], __s1[__i]))
Index: debug/hash_multimap.h
===================================================================
--- debug/hash_multimap.h	(r?vision 113135)
+++ debug/hash_multimap.h	(copie de travail)
@@ -181,7 +181,7 @@ namespace __debug
       erase(const key_type& __key)
       {
 	std::pair<iterator, iterator> __victims = this->equal_range(__key);
-	size_t __num_victims = 0;
+	std::size_t __num_victims = 0;
 	while (__victims.first != __victims.second)
 	{
 	  this->erase(__victims.first++);


More information about the Gcc-patches mailing list