This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs-970929: Missing symbols


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]