gcc bug ? (template, namespace and using)

Levente Farkas lfarkas@mindmaker.hu
Tue Sep 12 07:29:00 GMT 2000


hi,
try to compile the following example code and see the error message:
-------------------------- 
namespace n1
{
  int f(int i, int j) { return i+j; }
} // end of n1

namespace n2
{

template<typename T>                   // comment out this line
class A
{
public:
  virtual int f(int i)
  {
    using n1::f;
    return f(i, i+2);
  }
};

} // end of n2

int main()
{
  n2::A<int> a;                       // and use "n2::A a;" here
  int i = a.f(1);
}
-------------------------- 
[lfarkas@ai:/home/lfarkas/tmp]g++ test.cpp
test.cpp: In method `int n2::A<T>::f (int) [with T = int]':
test.cpp:25:   instantiated from here
test.cpp:16: no matching function for call to `n2::A<int>::f (int &,
int)'
test.cpp:14: candidates are: int n2::A<T>::f (int) [with T = int]
-------------------------- 
but if you comment out the template before A and use the non-template a in
main everything compile. it's a gcc bug or a c++ feature (IMHO the first).
and of course if I change A's f to:
{ return n1::f(i, i+2); }
everything wors again.
any tip ?
yours.

 -- Levente
 "The only thing worse than not knowing the truth is
  ruining the bliss of ignorance."


More information about the Gcc-bugs mailing list