New Bug (not in prior snapshots)

Fred Richardson frichard@bbn.com
Thu Dec 11 15:53:00 GMT 1997


The code pasted below gives an error:

  cd /d4m/frichard/BybRad/src/cmd/decoder++/
  gcc -v -save-temps -Wall -g -o tmp2 tmp2.cc
  Reading specs from /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.02/specs
  gcc version egcs-2.91.02 971206 (gcc-2.8.0)
   /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.02/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -g -Wall -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) tmp2.cc tmp2.ii
  GNU CPP version egcs-2.91.02 971206 (gcc-2.8.0) (sparc)
  #include "..." search starts here:
  #include <...> search starts here:
   /d4mutl/contrib/egcs/include/g++
   /usr/local/include
   /d4mutl/contrib/egcs/sparc-sun-solaris2.5.1/include
   /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.02/include
   /usr/include
  End of search list.
   /d4mutl/contrib/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.02/cc1plus tmp2.ii -quiet -dumpbase tmp2.cc -g -Wall -version -o tmp2.s
  GNU C++ version egcs-2.91.02 971206 (gcc-2.8.0) (sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.90.21 971202 (egcs-1.00 release).
  tmp2.cc: In function `int main()':
  tmp2.cc:160: Internal compiler error.
  tmp2.cc:160: Please submit a full bug report to `egcs-bugs@cygnus.com'.

  Compilation exited abnormally with code 1 at Thu Dec 11 18:45:36



tmp2.cc:
#include <list>

template < class N, class A >
class Base
{
public:
    class NN : public N
    {
        friend Base<N,A>;
        friend ostream& operator<<(ostream &os, const NN& n)
        {
            n.print(os);
            return os;
        }
    public:
        void print(ostream &os) const
        {
            os << "Base<N,A>::print()" << endl;
            N::print(os);
        }
    };

    typedef NN*                        NNPtr;
    typedef list<NNPtr>                NList;
    typedef NList::iterator            n_list_iter;

    class n_iter : public n_list_iter 
    {
        friend bool operator<(n_iter a, n_iter b)
        {
            return (a->ind() < b->ind());
        }
        friend bool operator>(n_iter a, n_iter b)
        {
            return (a->ind() > b->ind());
        }

    public:
        n_iter() {}
        n_iter(n_list_iter i) : n_list_iter(i) {}
        
        NN& operator*()
            { return *n_list_iter::operator*();};
        NN* operator->() 
            { return n_list_iter::operator*(); }
    };
private:
    NList    ns;
    n_iter new_n_aux(NN* nd)
    {
        ns.push_back(nd);
        n_iter  nodi = --ns.end();
        return (nodi);
    }
public:
    n_iter new_n()
    {
        return new_n_aux(new NN());
    }
    void del_n(n_iter itr) 
    {
        NN* n = itr.operator->();
        ns.erase(itr);
        delete n;
    }
    n_iter           beg_n()          {   return (ns.begin()); }
    n_iter           end_n()          {   return (ns.end());   }
};

template <class XN, class XA>
class YN : public XN
{
public:    
    YN() {};
    void print(ostream& os) const
    {
        os << "YN<XN,XA>::print() " << endl;
        XN::print(os);
    }
    friend ostream& operator<< (ostream& os, const YN& wn)
    {
        wn.print(os);
        return os;
    }
};

template <class XN, class XA>
class YA : public XA
{
public:    
    YA() {};
    void print(ostream &os) const
    {
        os << "YA<XN,XA>::print() " << endl;
        XA::print(os);
    }
    
    friend ostream& operator<<(ostream& os, const YA &wa)
    {
        wa.print(os);
        return os;
    }
};


template<class XN, class XA>
class XBase : public Base< YN<XN, XA>, YA<XN, XA> >
{
public:
    typedef     Base< YN<XN,XA>, YA<XN,XA> >    Net;
    typedef     Net::n_iter          n_iter;
    XBase() {};
};


class MyClass
{
public:
  struct ZN
  {
    void print(ostream &os) const
      {
        os << "MyClass::ZN::print()" << endl;
      }
    inline friend ostream& operator<<(ostream& os, const MyClass::ZN& nd)
      {
        nd.print(os);
        return os;
      }
  };
  struct ZA
  {
    void print(ostream& os) const
      {
        os << "MyClass::ZA::print()" << endl;
      }
    inline friend ostream& operator<<(ostream& os, const MyClass::ZA& ar)
      {
        ar.print(os);
        return os;
      }
  };

  typedef XBase<ZN,ZA>                    MyXBase;
  typedef MyXBase::n_iter                 my_n_iter;
  MyXBase                                 xbase;
};

main ()
{
  MyClass mine;
  MyClass::my_n_iter  n1, n2, n3, n4;

  n1 = mine.xbase.new_n();
  n2 = mine.xbase.new_n();
  n3 = mine.xbase.new_n();
  n4 = mine.xbase.new_n();
  
  cout << *n1 << endl;
  cout << *n2 << endl;
  cout << *n3 << endl;
  cout << *n4 << endl;
  
  mine.xbase.del_n(n1);
  mine.xbase.del_n(n2);
  mine.xbase.del_n(n3);
  mine.xbase.del_n(n4);
}





More information about the Gcc-bugs mailing list