This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: egcs-970929: Missing symbols
- To: Kurt Garloff <garloff at kg1 dot ping dot de>
- Subject: Re: egcs-970929: Missing symbols
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 02 Oct 1997 19:29:06 -0300
- Cc: egcs-bugs at cygnus dot com
- References: <Pine.LNX.3.95.971002084826.502A-100000@kg1.ping.de>
Kurt Garloff writes:
> egcs-970929 (2.90.11) seems to swallow some code on my machine
> (ix86-linux, glibc-2.0.5c, binutils-2.8.1.0.11) when using template
> friend functions.
C++ is not like that: a function and an instantiation of a template
function with the same set of arguments are not the same.
friend template functions must be declared before they are referred
to, and any references to their declarations must have template
braces.
template <class T>
class cplx;
template <class T>
T real (const cplx<T>& c);
template <class T>
ostream& operator << (ostream& ost, const cplx<T>& c);
> template <class T>
> class cplx
> {
[...] // note the empty angle brackets:
> friend T real<> (const cplx<T>& c);
> friend ostream& operator << <> (ostream&, const cplx<T>&);
> };
The changed-as-above code compiles and links successfully with the
current release of gcc.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
Universidade Estadual de Campinas, SP, Brasil