This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Internal compiler error in template class (fwd)
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: Internal compiler error in template class (fwd)
- From: <filmil at polip dot psc dot ac dot yu>
- Date: Thu, 21 Oct 1999 02:12:05 +0200 (CEST)
---------- Forwarded message ----------
Date: Thu, 21 Oct 1999 01:29:34 +0200 (CEST)
From: filmil@polip.psc.ac.yu
To: egcs-bugs@cygnus.com
Subject: Internal compiler error in template class
I have an ongoing project that has to do with various matrices
and their application. When I rewrote base class using templates
egcs reported an internal error. The command line used was
g++ -I. -c matrix_base.cc --verbose
Enclosed is the class implementation in two files, matrix_base.cc and
matrix_base.h. At the end of this message you will find --verbose
output from egcs.
Cheers.
(I hope you check this out asap since my work is on hold :)
-- Follows file matrix_base.cc --
/*
* implementacija bazne klase matrix_base i
* kontrolne klase matrix_info
*/
#include <iostream.h>
#include <stdlib.h>
#include <matrix_base.h>
void matrix_info::set_maxx( int setx)
{
maxx = setx;
}
int matrix_info::get_maxx( void)
{ return maxx; }
void matrix_info::set_maxy( int sety)
{
maxy = sety;
}
int matrix_info::get_maxy( void)
{ return maxy; }
void matrix_info::set_valid( int val)
{ is_valid = val;
}
int matrix_info::get_valid( void)
{ return is_valid;
}
int matrix_info::valid(void) { return get_valid(); }
// matrix base : implementacija
template <class T> class matrix_base;
template<class T>matrix_base<T>::matrix_base( int x = 2, int y = 2, int zero =0 )
{
minfo.set_valid(0); // mozda nije potrebno
val = new T [x*y];
if ( !val)
{
cout << "matrix_base: out of memory" << endl ; // znadem engleski, jelte?
exit(0);
}
minfo.set_maxx( x);
minfo.set_maxy( y);
minfo.set_valid(1);
}
template <class T>matrix_base<T>::~matrix_base(void)
{
minfo.set_valid(0);
delete val;
}
template <class T>
T& matrix_base<T>::get( int x, int y)
{
// za sada nema provere da li je lepo proslo (mozda nece ni trebati
return val[maxx*x + y]; // ovo znaci da su prvo smestene _vrste_
}
template <class T>
void matrix_base<T>::set( int x, int y, T& ent)
{
val[maxx*x + y] = ent;
}
-- Follows file matrix_base.h --
/*
* matrix_base
*
*/
#define __MATRIX_BASE_H
class matrix_info {
protected:
int maxx, maxy;
int is_valid; // da li sadrzi nesto smisleno
int other_info; // ovde idu ostale informacije o matrici
public:
void set_maxx( int setx);
int get_maxx(void);
void set_maxy( int sety);
int get_maxy(void);
void set_valid( int val);
int get_valid( void);
int valid(void);
};
template <class T> class matrix_base;
template <class T>
class matrix_base<T> {
protected:
T *val;
matrix_info minfo;
public:
// konstruktor
// x = broj kolona
// y = broj vrsta
// len = duzina jednog elementa matrice
template<class T>
matrix_base( int x = 2, int y = 2 , int zero = 0);
// destruktor
virtual ~matrix_base(void) = 0;
// tehnicke informacije o matrici
matrix_info& get_info(void);
// operacije s matricama
virtual matrix_base& add_sh( matrix_base& y);
virtual matrix_base& sub_sh( matrix_base& y);
virtual matrix_base& mul ( matrix_base& y);
virtual matrix_base& trans ( matrix_base& y);
template <class T> T& get( int x, int y);
template<class T> void set( int x, int y, T& val);
// provera kompatibilnosti matrica
// virtual friend int comp_add( matrix_base& x, matrix_base& y);
//virtual friend int comp_mul( matrix_base& x, matrix_base& y);
};
-- --verbose output
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.27/specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.27/cpp -lang-c++ -v -I. -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Di386 -D__ELF__ -Dunix -Dlinux -D__i386__ -D__ELF__ -D__unix__ -D__linux__ -D__i386 -D__unix -D__linux -Asystem(posix
) -D__EXCEPTIONS -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) matrix_base.cc /tmp/cca01393.ii
GNU CPP version egcs-2.90.27 980315 (egcs-1.0.2 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
.
/usr/include/g++
/usr/i386-redhat-linux/include
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.27/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.27/cc1plus /tmp/cca01393.ii -quiet -dumpbase matrix_base.cc -version -o /tmp/cca01393.s
GNU C++ version egcs-2.90.27 980315 (egcs-1.0.2 release) (i386-redhat-linux) compiled by GNU C version egcs-2.90.27 980315 (egcs-1.0.2 release).
matrix_base.cc: In method `matrix_base<T>::matrix_base(int = 2, int = 2, int = 0)':
matrix_base.cc:39: Internal compiler error.
matrix_base.cc:39: Please submit a full bug report to `egcs-bugs@cygnus.com'.
Linux polip.psc.ac.yu 2.0.35 #6 Thu Mar 11 12:46:53 CET 1999 i686 unknown