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

Marc Glisse marc.glisse@inria.fr
Sun Apr 17 21:10:00 GMT 2011


On Sun, 17 Apr 2011, Harald van Dijk wrote:

> 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?

This looks really close to 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47172
but apparently it wasn't fixed at the same time.

You want to open a new PR in bugzilla, which is the best place to report 
this kind of thing.

-- 
Marc Glisse



More information about the Gcc-help mailing list