This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
2.95: Internal compiler error (template instantiation)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: 2.95: Internal compiler error (template instantiation)
- From: Vince Del Vecchio <vince dot delvecchio at analog dot com>
- Date: Thu, 02 Sep 1999 18:38:28 -0400
When I compile the attached program with gcc 2.95, I get:
bug.cc: In method `void value_list::append<_List_iterator<pointer_val<value>,const pointer_val<value> &,const pointer_val<value> *> >(_List_iterator<pointer_val<value>,const pointer_val<value> &,const pointer_val<value> *>, _List_iterator<pointer_val<value>,const pointer_val<value> &,const pointer_val<value> *>)':
bug.cc:51: instantiated from here
bug.cc:55: Internal compiler error.
gcc version 2.95 19990728 (release)
sparc-sun-solaris2.5.1
-Vince Del Vecchio
vince.delvecchio@analog.com
#include <list>
template <class valtype>
class pointer_val {
public:
typedef valtype value_type;
pointer_val () : val (0), count (0) { }
pointer_val (const value_type& v)
: val (new valtype(v)), count (new int (1)) { }
pointer_val (const pointer_val& v)
: val (v.val), count (v.count) { if (count) ++*count; }
~pointer_val () { delref (); }
pointer_val& operator= (const pointer_val& v) {
if (v.count) ++*v.count;
delref ();
val = v.val;
count = v.count;
return *this;
}
const value_type& operator* () const { return *val; }
value_type& operator* () { return *operator-> (); }
const value_type* operator-> () const { return val; }
value_type* operator-> () {
if (*count == 1) return val;
val = new valtype(*val);
--*count;
count = new int (1);
return val;
}
private:
value_type *val;
int *count;
void delref () { if (count && !--*count) { delete val; delete count; } }
};
class value { };
typedef pointer_val<value> any_value;
class value_list : public value {
protected:
const value *x;
std::list<any_value> elts;
value_list& operator+= (const value_list& src) {
append (src.elts.begin(), src.elts.end());
return *this;
}
template <class in> void append (in s, in t) {
any_value v = *x;
for (in i = s; i != t; ++i)
*v = **i;
}
};
bug.ii.gz