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]
Other format: [Raw text]

[Bug c++/12169] New: False ambiguity in overloaded members from different base classes


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12169

           Summary: False ambiguity in overloaded members from different
                    base classes
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: preusser at ite dot inf dot tu-dresden dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu

The G++ compiler complains about an alleged ambiguity when two members with the
same names but differing signatures are inherited from two different base classes.

Workaround: Implementing forwarding methods in the subclass.

Example:

#include <iostream>

using namespace std;

class A {
public:
  void add(unsigned u, unsigned c) { cout << u << endl; }
};

class B {
public:
  void add(char const* c) { cout << c << endl; }
};

class C : public A, public B {};

int main() {
  C c;
  c.add(7, 5);
  c.add("abc");
}


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