GCC 4.6.0: cannot explicitly call overloaded base member function in C++0x mode with templates

Harald van Dijk harald@gigawatt.nl
Sun Apr 17 20:33:00 GMT 2011


Hello,

I am getting an unexpected compiler error for this code with GCC 4.6.0:

struct A {
  int f();
  int f(int);
};
template <typename> struct B : A
{
};
template <typename T> struct C : B<T>
{
  void g() {
    A::f();
  }
};

It is accepted with the default options, but is rejected with
-std=c++0x:

a.ii: In member function ‘void C<T>::g()’:
a.ii:11:11: error: cannot call member function ‘int A::f()’ without
object

It is accepted in GCC 4.5.2, both in default mode and in C++0x mode. Is
this a bug in GCC, or did C++0x make this invalid?

Cheers,
Harald



More information about the Gcc-help mailing list