Article View: gnu.g++.bug
Article #995template function def error
From: Steve Sullivan
Date: Tue, 29 Sep 1992 15:07
Date: Tue, 29 Sep 1992 15:07
46 lines
1344 bytes
1344 bytes
It appears that the function definition:
template<type> func() {...}
is not handled correctly by g++.
The following program doesn't compile under g++ (gcc) 2.2.2
on a Sparc 2, SunOs 4.1. Yet it seems to me it should.
Is there a fix for this?
===== begin program =================
template <class T>
class QI {
public:
QI();
void print();
private:
T item;
QI *next;
};
template <class T>
QI<T>::QI() {}
template <class T>
void QI<T>::print();
// **** following line is line 21, and causes error:
QI<int> afunc() {
QI<int> alpha;
return alpha;
}
main () {
QI<int> beta;
}
=============== end program ===================
diagnostics printed by g++:
> g++ -c testc.cc
testc.cc:21: semicolon missing after declaration of `QI<int>'
testc.cc: In function `int afunc ()':
testc.cc:23: aggregate value used where an integer was expected
Exit 1
Technical Details
Message-ID:
<199209300307.AA29191@teal.csn.org>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!csn.org!sullivanShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!csn.org!sullivan From: sullivan@csn.org (Steve Sullivan) Subject: template function def error Message-ID: <199209300307.AA29191@teal.csn.org> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 29 Sep 1992 15:07:15 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 48