egcs-970929: Missing symbols

Alexandre Oliva
Thu Oct 2 15:34:00 GMT 1997

Kurt Garloff writes:

>  egcs-970929 (2.90.11) seems to swallow some code on my machine
>  (ix86-linux, glibc-2.0.5c, binutils- 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

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
Universidade Estadual de Campinas, SP, Brasil

More information about the Gcc-bugs mailing list