[PATCH][C++] Fix PR29433, make C++ use a lot less time/memory

Richard Guenther rguenther@suse.de
Sat Dec 9 16:28:00 GMT 2006


On Sat, 9 Dec 2006, Gabriel Dos Reis wrote:

> On Sat, 9 Dec 2006, Richard Guenther wrote:
> 
> | On 08 Dec 2006 19:39:35 -0600, Gabriel Dos Reis <gdr@cs.tamu.edu> wrote:
> | > Richard Guenther <rguenther@suse.de> writes:
> | >
> | > [...]
> | >
> | > | > I think it would be best if we could track this down, because that might
> | > | > allow us to really completely nail this problem.
> | > |
> | > | Ok, here's one testcase that fails
> | > |
> | > | template <class _Tp> class auto_ptr {};
> | > | template <class _Tp>
> | > | class counted_ptr
> | > | {
> | > | public:
> | > |   auto_ptr<_Tp> auto_ptr();
> | > | };
> | > |
> | > | with
> | > |
> | > | t.ii:6: error: declaration of 'auto_ptr<_Tp> counted_ptr<_Tp>::auto_ptr()'
> | > | t.ii:1: error: changes meaning of 'auto_ptr' from 'class auto_ptr<_Tp>'
> | >
> | > That means GCC is functionning correctly -- for once, GCC hasn't
> | > screwed up its data structures :-)
> | >
> | > I believe the program is invalid.  It should have been
> | >
> | >    ::auto_ptr<_Tp> auto_ptr();
> |
> | doh!  Ok, then libstdc++ is broken as well, as is Boost if I remember
> | correctly.
> 
> libstdc++ should be fixed (this would not be the first time :-) -- and
> I'm sure Boost too.

I can fix the C++ failures with


2006-12-09  Richard Guenther  <rguenther@suse.de>

	* include/bits/stl_tree.h (struct _Rb_tree): Qualify types.

	* g++.dg/warn/implicit-typename1.C: Qualify types.
	* g++.dg/parse/crash12.C: Likewise.
	* g++.dg/tree-ssa/pr22444.C: Likewise.

Index: gcc/testsuite/g++.dg/warn/implicit-typename1.C
===================================================================
*** gcc/testsuite/g++.dg/warn/implicit-typename1.C	(revision 119690)
--- gcc/testsuite/g++.dg/warn/implicit-typename1.C	(working copy)
*************** template <typename T> struct C {
*** 13,17 ****
  };
  
  template <typename T> struct A : public C<T> {
!   typedef X<int> X;
  };
--- 13,17 ----
  };
  
  template <typename T> struct A : public C<T> {
!   typedef ::X<int> X;
  };
Index: gcc/testsuite/g++.dg/parse/crash12.C
===================================================================
*** gcc/testsuite/g++.dg/parse/crash12.C	(revision 119690)
--- gcc/testsuite/g++.dg/parse/crash12.C	(working copy)
*************** template <class _Tp>
*** 9,16 ****
  class counted_ptr
  {
  public:
!   counted_ptr(auto_ptr<_Tp>& __a);		// { dg-error "candidate" }
!   auto_ptr<_Tp> auto_ptr();
  };
  
  template <class _Tp>
--- 9,16 ----
  class counted_ptr
  {
  public:
!   counted_ptr(::auto_ptr<_Tp>& __a);		// { dg-error "candidate" }
!   ::auto_ptr<_Tp> auto_ptr();
  };
  
  template <class _Tp>
Index: gcc/testsuite/g++.dg/tree-ssa/pr22444.C
===================================================================
*** gcc/testsuite/g++.dg/tree-ssa/pr22444.C	(revision 119690)
--- gcc/testsuite/g++.dg/tree-ssa/pr22444.C	(working copy)
*************** namespace std
*** 103,112 ****
    };
    template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc = allocator<_Val> > struct _Rb_tree
    {
!     typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other _Node_allocator;
      typedef _Rb_tree_node_base* _Base_ptr;
      typedef const _Rb_tree_node_base* _Const_Base_ptr;
!     typedef _Rb_tree_node<_Val> _Rb_tree_node;
      typedef _Key key_type;
      typedef _Val value_type;
      typedef value_type* pointer;
--- 103,112 ----
    };
    template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc = allocator<_Val> > struct _Rb_tree
    {
!     typedef typename _Alloc::template rebind<std::_Rb_tree_node<_Val> >::other _Node_allocator;
      typedef _Rb_tree_node_base* _Base_ptr;
      typedef const _Rb_tree_node_base* _Const_Base_ptr;
!     typedef std::_Rb_tree_node<_Val> _Rb_tree_node;
      typedef _Key key_type;
      typedef _Val value_type;
      typedef value_type* pointer;
Index: libstdc++-v3/include/bits/stl_tree.h
===================================================================
*** libstdc++-v3/include/bits/stl_tree.h	(revision 119690)
--- libstdc++-v3/include/bits/stl_tree.h	(working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 320,332 ****
             typename _Compare, typename _Alloc = allocator<_Val> >
      class _Rb_tree
      {
!       typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other
                _Node_allocator;
  
      protected:
        typedef _Rb_tree_node_base* _Base_ptr;
        typedef const _Rb_tree_node_base* _Const_Base_ptr;
!       typedef _Rb_tree_node<_Val> _Rb_tree_node;
  
      public:
        typedef _Key key_type;
--- 320,332 ----
             typename _Compare, typename _Alloc = allocator<_Val> >
      class _Rb_tree
      {
!       typedef typename _Alloc::template rebind<std::_Rb_tree_node<_Val> >::other
                _Node_allocator;
  
      protected:
        typedef _Rb_tree_node_base* _Base_ptr;
        typedef const _Rb_tree_node_base* _Const_Base_ptr;
!       typedef std::_Rb_tree_node<_Val> _Rb_tree_node;
  
      public:
        typedef _Key key_type;



More information about the Gcc-patches mailing list