problems with implicit template specialization

Andrey Slepuhin pooh@msu.ru
Wed Oct 8 02:37:00 GMT 1997


Hi,

I have troubles with a following code, which works fine with gcc
2.7.2.2:

-------------------------------------------------------------------------
template <class T> class A
{

  T* a;

public:
  
  A (T* p) { a=p; }
 ~A () {}
 
  friend T* f(A<T>&); 

};

template <class T> T* f(A<T>& x)
{
  return x.a;
}

void main()
{
  int x=2;
  A<int> y(&x);
  f(y);			// this line cause an error at link stage
}
---------------------------------------------------------------------------
pooh@forest:~/tmp$ /local/egcs/bin/g++ tmp.C 
ld: 0711-317 ERROR: Undefined symbol: .f(A<int> &)
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
collect2: ld returned 8 exit status
---------------------------------------------------------------------------
replacing f(y) by f<int>(y) all works fine. Is this a bug in egcs or
if I cannot use such implicit template specialization, why I didn't get
any errors or warnings about undeclared function f(A<int>&)?
I am using egcs-970929 on AIX 4.2.1.

Andrey Slepuhin,
Moscow State University



More information about the Gcc-bugs mailing list