egcs-1.1a - template bug

Ryszard Kabatek rysio@rumcajs.chemie.uni-halle.de
Fri Sep 4 07:34:00 GMT 1998


There is a serious template bug in egcs-1.1a 
(not in egcs-1.0.2 or gcc-2.8.1).

My configuration:
Linux (RedHat 5.1), Pentium II
binutils-2.9.1.0.4-2
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)


The first sample (sample1.cc) with a vector as member does compile well.

The second (sample2.cc) with inheritance from std::vector causes an
internal compiler error:
g++ sample2.cc

sample2.cc: In method `vectorN<double,100>::vectorN<double, 100>(unsigned
int = N, const double & = T())':
sample2.cc:12:   instantiated from here
sample2.cc:8: Internal compiler error.
sample2.cc:8: Please submit a full bug report to `egcs-bugs@cygnus.com'.

The third sample (sample3.cc), with inheritance from std::vector and
a template defualt parameter:

g++ sample3.cc
The only way to end the compilation was ^C.
No message.


/////////////
// sample1.cc
/////////////
# include <vector>

template <class T, int N> class vectorN {
    vector<T> v;
  public:
    vectorN(const T& value = T()) : v(N, value) {}
};

int main() {
  vectorN<double> v;
}

////////////
//sample2.cc
////////////
# include <vector>

template <class T, int N> class vectorN : public vector<T> {
public:
 vectorN(const T& value = T()) : vector(N, value) {}
};

int main() {
  vectorN<double, 100> v;
}

////////////
//sample3.cc
////////////
# include <vector>

template <class T, int N = 100> class vectorN : public vector<T> {
public:
 vectorN(const T& value = T()) : vector(N, value) {}
};

int main() {
  vectorN<double> v;
}


Ryszard Kabatek

Martin-Luther University Halle-Wittenberg
Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129
e-mail: kabatek@chemie.uni-halle.de




More information about the Gcc-bugs mailing list