Template bug?
Manuel Menezes de Sequeira
mms@torga.iscte.pt
Wed May 19 10:20:00 GMT 1999
I'm not sure whether it is a compiler bug, but KAI C++
correctly compiled the code below and I've checked
the Draft Standard and it seems to me to be legal code.
My version of egcs is 1.1.2 distributed in RedHat 6.0.
// Template 1:
template <class R, class T>
R f(T i) {
// do something
}
// Template 2 (specialization):
template <class R, class T>
R f(T* i) {
// do something else
}
int main() {
int i = 0;
double d;
d = f<double,int>(i); // should instantiate template 1
d = f<double>(i); // should instantiate template 1
d = f<double,int*>(&i); // should instantiate template 1
d = f<double,int>(&i); // should instantiate template 2
// Up to here, all is well.
// EGCS reports ambiguity in this line:
d = f<double>(&i); // should instantiate template 2
}
--
Manuel Menezes de Sequeira Manuel.Sequeira@iscte.pt
Tel: +351.1.7903909 Mobile: +351.936.2337428
Fax: +351.1.7903099 URL: http://torga.iscte.pt/~mms/
Gab. 9, DCTI, ISCTE, Av. Forças Armadas, 1600 LISBOA, Portugal
More information about the Gcc-bugs
mailing list